Skip to content

Log series of values or files#

Chart with graphs

A series field consists of a sequence of numerical values, strings, or files. These can be loss during training, text logs after every iteration, or sample predictions.

Neptune automatically displays all numerical series as charts and image series as an interactive gallery.

Constructing a series#

Numerical series (FloatSeries)#

You can log a series of float or int values with the following methods from the Neptune client library:

  • append() – adds one value at a time to the field.
  • extend() – adds a collection of values to the field. (This can help reduce requests to the Neptune servers.)
Example: Logging metrics
for epoch in range(100):
    # your training loop
    acc = ...
    loss = ...

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

If you try to append unsupported values, such as Inf, NaN, or None, these will be skipped when constructing the series. To log them to Neptune, you can alternatively convert such values to for example 0.

See charts in Neptune 

Text series (StringSeries)#

You can log a series of strings with the following methods from the Neptune client library:

  • append() – adds one value at a time to the field.
  • extend() – adds a collection of values to the field.
for iteration in range(100):
    run["logs"].append(iteration_config)

If you add a StringSeries field as a column to the experiments table, the last entry is displayed.

Tip

By default, two automatically logged StringSeries are the stdout and stderr fields, which track the standard streams.

Learn more: Logging system metrics

File series (FileSeries)#

View a series of images in Neptune

You can likewise use the append() and extend() methods to log a series of images. The resulting field type is FileSeries.

You can pass PIL, Matplotlib, or Seaborn figure objects as the argument:

import neptune

run = neptune.init_run()
for iteration in range(100):
    pil_image = ...
    run["train/distribution"].append(pil_image)

Passing a file path

If you supply a file path, use the File constructor:

from neptune.types import File

for i in range(100):
    run["image_preds"].append(File(f"image_pred_{i}.png"))

In the app, you can browse the logged series in the Images tab.

See example in Neptune 

Related

Logging images

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.

Appending multiple values to series field#

You can use append() to log a single value to a series field at a time.

To append multiple values to the same series at once, use extend() instead.

Does not work

>>> run["metric"].append([0.51, 0.52])
<warning>

Works

>>> run["metric"].extend([0.51, 0.52])

Logging to multiple series at once#

To append single values to multiple series at once, you can pass a dictionary where each key represents a field name:

run["train"].append({"acc": acc, "loss": loss})

The above values will be logged to two separate series fields: acc and loss.

Downloading or fetching series data#

You can use the Neptune API to fetch all of the values or just the last value of a series field.

For StringSeries or FloatSeries fields, you can use fetch_last() or fetch_values().

Fetch final logged value of float series
>>> import neptune
>>> run = neptune.init_run(with_id="CLS-15", mode="read-only")
>>> run["train/loss"].fetch_last()
0.15250000000000002

For FileSeries fields, you can use download() or download_last().

Fetch all logged images of file series
>>> run["train/predictions"].download(destination="downloads") # (1)!
  1. The destination parameter is optional. If left out, the files are downloaded to the current working directory.