Skip to main content
App version: 3.4.14

Metrics

A metric can be accuracy, MSE, or any numerical value. Neptune app displays all float series as charts.

Log metrics

To log a numerical series, use the log_metrics() function:

from neptune_scale import Run


run = Run(experiment_name=...)

for step in epoch:
# your training loop
run.log_metrics(
data={"acc": 0.78},
step=step,
)
info

Neptune supports 64-bit floating-point numbers, which have a precision of 16 digits.

To log multiple metrics in a single call, pass multple key-value pairs to the data dictionary:

run.log_metrics(
data={"loss": 0.13, "acc": 0.79},
step=step,
)

Setting step values

To specify the index of metric values, use the step parameter:

run.log_metrics(
data={"loss": 0.13, "acc": 0.79},
step=2,
)

The step argument can be an integer or floating point value.

Float values can be useful, for example, as substeps:

run.log_metrics(
data={"loss": 0.11, "acc": 0.81},
step=2.1,
)
note

Within a particular metric, the step values must increase:

run.log_metrics(data={"loss": 0.13}, step=2)
run.log_metrics(data={"loss": 0.11}, step=3) # OK
run.log_metrics(data={"loss": 0.12}, step=1) # not OK

If you're logging separate FloatSeries attributes, the step doesn't have to increase across log_metrics() calls within the same run:

run.log_metrics(data={"loss": 0.13}, step=2)
run.log_metrics(data={"acc": 0.68}, step=1) # OK - different attribute

Setting custom timestamp

To provide a custom timestamp, pass a Python datetime value to the timestamp argument:

run.log_metrics(
data=...,
step=...,
timestamp=datetime.utcnow(),
)

If the timestamp argument isn't provided, the current time is used.

note

If timestamp.tzinfo is not set, the time is assumed to be in the local timezone.

Logging metrics from different processes

You can safely log metrics to the same run in separate processes, as long as steps aren't logged out of order within the same series attribute.

For details, see Log from different processes.

Logging metrics to fork runs

When forking a run, metrics are inherited up until and including the step specified as the fork point.

For details, see Fork an experiment.

Logging incomplete metrics

You can log partial series results and mark them as preview values.

For details, see Metric previews.

View metrics in the app

You can view the logged metrics in the Neptune app:

  • To view all metrics logged to a single run, navigate the the Attributes tab of the selected run.
  • To display a metric across multiple runs, navigate to the Charts tab.
  • To display metrics in your dashboards and reports, configure a chart widget.

Download metrics as CSV

To download a FloatSeries attribute as a CSV file:

  1. Go the Attributes tab of a run.
  2. From the attribute list, select a metric.
  3. From the chart toolbar, select DownloadDownload data (CSV).

You can download one file per metric.

Error handling

See log_metrics: Exceptions.