Search notes:

Convert numpy arrays to torch tensor

The following snippet converts a list of numpy arrays to torch tensors.
import numpy
import torch

data_np    = [
              numpy.array([
                     [1.1, 2.1, 3.2],
                     [4.2, 5.8, 6.9]
                  ]),
              numpy.array([
                     [ 7.2,  8.0],
                     [ 9.1, 10.1],
                     [11.7, 12.6]
                 ])
             ]


data_torch = list(map(torch.tensor, data_np ))

print(data_torch)

Index