Reputation: 4318
What is the equivalent function of
x = tf.transpose(y, perm=[2, 0, 1])
in pytorch? For instance, If I have
pytorch
import torch y=torch.randn(10, 480, 640)
How can I convert y to x in pytorch?
y
x
Upvotes: 1
Views: 499
Reputation: 40698
You can use torch.Tensor.permute:
torch.Tensor.permute
>>> x = y.permute(2, 0, 1)
Upvotes: 2