Converting python list to pytorch tensor - Stack Overflow
stackoverflow.com › questions › 60090093Feb 06, 2020 · You can directly convert python list to a pytorch Tensor by defining the dtype. For example, import torch a_list = [3,23,53,32,53] a_tensor = torch.Tensor (a_list) print (a_tensor.int ()) >>> tensor ( [3,23,53,32,53]) Share answered Jan 10, 2021 at 2:45 Devanshi 71 1 4 Add a comment 3
Converting a list to tensor - PyTorch Forums
discuss.pytorch.org › t › converting-a-list-toMay 10, 2019 · Converting a list to tensor. Niki (Niki) May 10, 2019, 1:10pm #1. Any ways for converting a list as follows to tensor? a = [ [1,2,3], [4,5,6], [1]] b = torch.tensor (a) For this one, I am getting this error: ValueError: expected sequence of length 3 at dim 1 (got 1) 1 Like. ptrblck May 10, 2019, 1:13pm #2. This won’t work, as your input has ...