Log series of values or files#
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.)
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
.
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.
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
)#
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:
In the app, you can browse the logged series in the Images tab.
Related
Setting custom index values#
You can specify custom index values with the step
argument:
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.
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:
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()
.
>>> 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()
.
>>> run["train/predictions"].download(destination="downloads") # (1)!
- The
destination
parameter is optional. If left out, the files are downloaded to the current working directory.