torch tensor reshape from torch.Size([1, 16384, 3]) to torch.Size([1, 128, 128, 3])
I have a torch tensor shaped, torch.Size([1, 16384, 3]) and I want it to be torch.Size([1, 128, 128, 3]).
How can I do that?

You can use .view method, but make sure you don't truncate or extropolate dimension as you will get a Runtime Error.
I suggest:

# Your tensor
a = torch.ones((1, 16384, 3))
a = a.view((1, 128, 128, 3))

# Test if it works
print(a.size())
&gt;&gt; torch.Size([1, 128, 128, 3])

Optional: Also you can used up to 1 inferred size value like this
a = torch.ones((1, 16384, 3))
# Place -1 wherever you want an inferred value but make sure only one -1. 
a = a.view(1, -1, 128, 3))

# or 

a = a.view(1, 128, 128, -1))


Sarthak Jain
