Skip to content

Log metrics#

A metric can be accuracy, MSE, or any numerical value. You can log scores and metrics as

  • single values, with = assignment.
  • series of values, with the append() method. Each append() call adds a value to the field.

Neptune displays all value series as charts.

Log scores (single value)
run["score"] = 0.97
run["test/acc"] = 0.97
Log metrics (series of values)
for epoch in range(100):
    # your training loop
    acc = ...
    loss = ...
    metric = ...

    run["train/accuracy"].append(acc)
    run["train/loss"].append(loss)
    run["metric"].append(metric)

See in Neptune 

Setting custom index values#

You can specify custom index values with the step argument:

run["metric"].append(
    value=acc,
    step=i,
)

The entries logged for step must be strictly increasing Int or Float values.

This is effectively like setting custom values for the x axis of a chart.

Batching notes#

In some cases, logging a large amount of metrics at once may exceed rate limits.

To optimize batching when creating multiple series fields in a single statement, iterate through the fields in the outer loop and the values in the inner loop:

Improves batching
for field in range(500):
    for i in range(1000):
        run[f"my_metric_{field}"].append(i)
Doesn't batch well
for i in range(1000):
    for field in range(500):
        run[f"my_metric_{field}"].append(i)