I think amazing_coder’s code is right.
x[…, 3] = torch.tensor([1,2,3,4])
In this case, think about your code.
x90 = x.transpose(2, 3)
than x90 is
tensor([[[[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.],
[1., 2., 3., 4.]]]])
It’s not right way about rotate 90 degree. This should have a flip.