Hi,
How can I change int list to torch tensor ?
[1,2,3] -> [tensor(1), tensor(2), tensor(3)]
Hi,
How can I change int list to torch tensor ?
[1,2,3] -> [tensor(1), tensor(2), tensor(3)]
how about this?
In [1]: import torch
In [2]: x = [1, 2, 3]
In [3]: [torch.tensor(a, dtype=torch.long) for a in x]
Out[3]: [tensor(1), tensor(2), tensor(3)]