Tensor reshaping

I need to reshape a tensor with size [3, 32] now I need to change the dimension so that the shape becomes [1, 3, 32] ?

Is there any similar method like reshape in numpy for torch tensors?

Thanks.

1 Like

You can do:

x = x.view(1, 3, 32)
2 Likes

Thank you so much for the quick reply.

You can do: x = x.unsqueeze(0)

3 Likes