Hi,
So I have a Pytorch Tensor of size [4055, 4, 80]. Now I would like to get a resultant Pytorch tensor of size [4055, (4*80)] or [4055, 320]. How can I do that?
You can flatten the last two dimensions via:
x = torch.randn(4055, 4, 80)
print(x.size())
# torch.Size([4055, 4, 80])
y = x.view(x.size(0), -1) # keep dim0, flatten last dimensions
print(y.size())
# torch.Size([4055, 320])
z = torch.flatten(input=x, start_dim=1, end_dim=-1)
print(z.size())
# torch.Size([4055, 320])
1 Like