feed_me_pi
feed_me_pi

Reputation: 177

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.

Upvotes: 4

Views: 1106

Answers (1)

Dishin H Goyani
Dishin H Goyani

Reputation: 7693

You may want torch.stack

xs = torch.stack(xs)

Upvotes: 4

Related Questions