log_metrics()
Logs the specified metrics to a Neptune run.
You can log metrics representing a series of numeric values. Pass the metadata as a dictionary {key: value}
with:
key
: path to where the metadata should be stored in the run.value
: the piece of metadata to log.
For example, {"metrics/accuracy": 0.89}
. In the attribute path, each forward slash /
nests the attribute under a namespace. Use namespaces to structure the metadata into meaningful categories.
Parameters
Raises
ValueError
– Whenpreview_completion
is specified for non-preview metrics or whenpreview_completion
is outside the range of 0.0–1.0.
Step requirements
-
Within a particular metric, steps must be increasing.
- Steps can be logged out of order only if the value is a preview value logged after the last regular step.
-
In fork runs, the step can't be smaller than the fork step. For details, see Forking.
-
For examples, see Log metrics: Setting step values.
Exceptions
Neptune may warn or raise exceptions if there are malformed or inconsistent values.
Non-increasing steps
If steps logged to the client are not increasing, Neptune raises the NeptuneSeriesStepNonIncreasing
warning. This doesn't terminate the training process.
This step order requirement doesn't apply to preview values. For example, you can log a preview for step 10 and then again for step 9 without errors, if steps 9, 10, and all the following steps have preview
set to True
.
You can override the default behavior by implementing your own callbacks to handle error scenarios. For details, see Neptune API error handling.
Example
Create a run and log metrics:
from neptune_scale import Run
with Run(...) as run:
run.log_metrics(
data={"loss": 0.14, "acc": 0.78},
step=1.2,
)