Skip to content

Log arrays and tensors#

Multidimensional arrays or tensors (logged with, for example, PyTorch or TensorFlow) can be displayed as images in Neptune.

Logging NumPy arrays#

You can log 2D or 3D NumPy arrays directly from memory.

To visualize the array as an image, use the upload() method together with File.as_image():

import numpy as np
import neptune
from neptune.types import File

run = neptune.init_run()

im_array = np.random.rand(100, 100, 3) * 255
run["np_image"].upload(File.as_image(im_array))

To log a series of NumPy arrays, use append() instead:

for epoch in range(data):
    im_array = ...
    run["train/distribution"].append(File.as_image(im_array))

See example in Neptune 

Logging tensors#

You can log 2D or 3D tensors directly from memory.

To visualize the tensor as an image, use the upload() method together with File.as_image():

TensorFlow#

import tensorflow as tf
from neptune.types import File

tf_tensor = tensorflow.random.uniform(shape=[10, 20, 3])
run["tf_image"].upload(File.as_image(tf_tensor))

You can also log a series of TensorFlow tensors:

from neptune.types import File

for epoch in range(data):
    tf_tensor = ...
    run["train/distribution"].append(File.as_image(tf_tensor))

See example in Neptune 

PyTorch#

import torch
from neptune.types import File

torch_tensor = torch.rand(30, 30)
run["torch_tensor"].upload(File.as_image(torch_tensor))

You can also log a series of PyTorch tensors:

from neptune.types import File

for epoch in range(data):
    torch_tensor = ...
    run["train/distribution"].append(File.as_image(torch_tensor))

See example in Neptune 

Logging 1D arrays#

If your data is a 1D array (such as audio data, waveform, or time series) you can log it as a FloatSeries.

Use the extend() method to log the values:

run["array"].extend(arr)

Or use the append() method to add values one by one:

for value in arr:
    run["array"].append(value)

You can then display the values of series field (in this case, "array") as a chart in Neptune.

See example charts in Neptune 

Related