mirror of
https://github.com/clearml/clearml
synced 2025-06-23 01:55:38 +00:00
Add a single metric reporting example
This commit is contained in:
parent
a18b7b3271
commit
e695251dd4
36
examples/reporting/single_scalar_reporting.py
Normal file
36
examples/reporting/single_scalar_reporting.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# ClearML - Example of manual single value scalars reporting
|
||||||
|
#
|
||||||
|
from clearml import Task
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Connecting ClearML with the current process,
|
||||||
|
# from here on everything is logged automatically
|
||||||
|
task = Task.init(project_name="examples", task_name="Scalar reporting (Single Value)")
|
||||||
|
|
||||||
|
# Get the task logger,
|
||||||
|
# You can also call Task.current_task().get_logger() from anywhere in your code.
|
||||||
|
logger = task.get_logger()
|
||||||
|
|
||||||
|
# report scalars
|
||||||
|
logger.report_single_value(name="metric_A", value=125)
|
||||||
|
logger.report_single_value(name="metric_B", value=305.95)
|
||||||
|
logger.report_single_value(name="metric_C", value=486)
|
||||||
|
|
||||||
|
# force flush reports
|
||||||
|
# If flush is not called, reports are flushed in the background every couple of seconds,
|
||||||
|
# and at the end of the process execution
|
||||||
|
logger.flush(wait=True)
|
||||||
|
|
||||||
|
# get scalars
|
||||||
|
# Getting one metric
|
||||||
|
metric_B = task.get_reported_single_value('metric_B')
|
||||||
|
print('metric_B is', metric_B)
|
||||||
|
|
||||||
|
# Getting all metrics at once
|
||||||
|
metric_all = task.get_reported_single_values()
|
||||||
|
print('All metrics', metric_all)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user