python - How to load a list of numpy arrays to pytorch ...
https://stackoverflow.com/questions/4442919908.06.2017 · Here is how to convert numpy arrays to tensors: import torch import numpy as np n = np.arange(10) print(n) #[0 1 2 3 4 5 6 7 8 9] t1 = torch.Tensor(n) # as torch.float32 print(t1) #tensor([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) t2 = torch.from_numpy(n) # as torch.int32 print(t2) #tensor([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=torch.int32)