Skip to content

Logging arrays and tensors#

Multi-dimensional 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
from neptune.new.types import File

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 log() instead:

for epoch in range(data):
    im_array = ...
    run["train/distribution"].log(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():

import tensorflow as tf
from neptune.new.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 tensors:

from neptune.new.types import File

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

See example in Neptune ≫

import torch
from neptune.new.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 tensors:

from neptune.new.types import File

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

See example in Neptune ≫