'IndexError: Dimension out of range (expected to be in range of [-2, 1], but got 3)

I created a random function with the line below

x = torch.randn(4, 3)

and used the transpose function as shown here

torch.transpose(x, 0, 1)

I got the error line below. Who can assist with a solution


IndexError                                Traceback (most recent call last)
<ipython-input-19-28494ba2cedc> in <module>()
----> 1 torch.transpose(x, 0, 3)

IndexError: Dimension out of range (expected to be in range of [-2, 1], but got 3)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source