How can I convert a FloatTensor of size 3 to size(1,3)?

eg. a = torch.rand(3) # [torch.FloatTensor of size 3]

which operation can I convert this tensor to size 1*3 ???

You can either use .view(1, 3), or .unsqueeze(0).

1 Like

I tried it but doesn’t work…

ah…it works…sorry, I made some mistakes just now…thank you for your help!!!