How to turn a list of tensor to tensor?

I was always doing something like:

a = [torch.FloatTensor([1]).view(1, -1), torch.FloatTensor([2]).view(1, -1)]
torch.stack(a)

Gives me:

(0 ,.,.) = 
  1

(1 ,.,.) = 
  2
[torch.FloatTensor of size 2x1x1]
18 Likes