Converting python list to pytorch tensor
I have a problem converting a python list of numbers to pytorch Tensor : 
this is my code :  

caption_feat = [int(x)  if x &lt; 11660  else 3 for x in caption_feat]


printing caption_feat gives : [1, 9903, 7876, 9971, 2770, 2435, 10441, 9370, 2] 
I do the converting like this : tmp2 = torch.Tensor(caption_feat)
now printing tmp2 gives : tensor([1.0000e+00, 9.9030e+03, 7.8760e+03, 9.9710e+03, 2.7700e+03, 2.4350e+03,
        1.0441e+04, 9.3700e+03, 2.0000e+00]) 
However I expected to get : tensor([1. , 9903, , 9971. ......]) 
Any Idea?

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())

&gt;&gt;&gt; tensor([3,23,53,32,53])

