Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

list of tensors into tensors

I have a list like

xs = [tensor1, tensor2, tensor3....]

I want to change it into a tensor so that I can feed xs and ys into the Pytorch DataLoader. I tried this,

xs = torch.Tensor(xs)

but it doesn't work as the individual elements are not items but tensors.

like image 651
feed_me_pi Avatar asked Sep 17 '25 06:09

feed_me_pi


1 Answers

You may want torch.stack

xs = torch.stack(xs)
like image 159
Dishin H Goyani Avatar answered Sep 19 '25 05:09

Dishin H Goyani