How to transpose 3D matrix in PyTorch v0.2

I want to transpose a 3D matrix, it can be done by .t() in PyTorch v0.1. However, I update my PyTorch version and I can’t do it this way.
The error log is like this:
raise RuntimeError(“t() expects a 2D Variable, but self is {}D”.format(self.dim()))
RuntimeError: t() expects a 2D Variable, but self is 3D

1 Like

use x.permute() -> http://pytorch.org/docs/master/tensors.html?highlight=permute#torch.Tensor.permute

3 Likes

You are right. Thank you.

If you just want to reverse the dimension, you could use x.Thttps://pytorch.org/docs/master/tensors.html#torch.Tensor.T