Hello,
I would like to reshape a tensor (or alter the dimension of the tensor) such that the elements do not change location. Here is a simple example:
torch.Size([2, 2, 2, 2])
tensor([[[[1., 0.],
[0., 0.]],
[[0., 1.],
[0., 0.]]],
[[[0., 0.],
[2., 0.]],
[[0., 0.],
[0., 2.]]]], dtype=torch.float64)
This is a 2x2 tensor of 2x2 tensors, which looks like the left tensor in the image. I would like the tensor to become a 4x4 tensor, which looks like the right tensor in the image:
I have not been getting the desired result with view, reshape or permute
torch.reshape(z,(4,4)) gives the following which positions the element incorrectly.
reshape:
tensor([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 2., 0.],
[0., 0., 0., 2.]], dtype=torch.float64)
I need to this for a 1600x9x1600x2 tensor, to make it a 1600^2 x 18 tensor.
Thank you in advance!