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.
If steps logged to the client are not increasing, Neptune raises the NeptuneSeriesStepNonIncreasing
exception and terminates the training process.
You can override the default behavior by implementing your own callbacks to handle error scenarios. For details, see Neptune API error handling.
Parameters
Name | Type | Default | Description |
---|---|---|---|
data | Dict[str, Union[float, int]] | None | Dictionary of metrics to log. Each metric value is associated with a step. To log multiple metrics at once, pass multiple key-value pairs. |
step | Union[float, int] | None | Index of the log entry. Must be increasing. Tip: Using float rather than int values can be useful, for example, when logging substeps in a batch. |
timestamp | datetime , optional | None | Time of logging the metadata. If not provided, the current time is used. If provided, and timestamp.tzinfo is not set, the time is assumed to be in the local timezone. |
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,
)
Note: To correlate logged values, make sure to send all metadata related to a step in a single log_metrics()
call, or specify the step explicitly.
When the run is forked off an existing one, the step can't be smaller than the step value of the fork point.