After reading the documentation for Tensor.view,
https://pytorch.org/docs/stable/tensors.html#torch.Tensor.view 2.6k
it seems like it could be used to swap two dimension in a tensor, but this is not the case:
a=torch.randn((1,2,3,4))

# Swap 2nd and 3rd dimensions using split and stack
b = torch.stack(a.split(1, 1), 3).squeeze(1)  # has shape (1, 3, 2, 4)

# Swap 2nd and 3rd dimensions using tensor.view
c = a.view((1, 3, 2, 4))  # has shape (1, 3, 2, 4)

(b == c).all()  # False

Am I misunderstanding the documentation? What exactly does tensor.view() do in the example above?