Dalek
Dalek

Reputation: 4318

converting tensorflow transpose to pytorch

What is the equivalent function of

x = tf.transpose(y, perm=[2, 0, 1])

in pytorch? For instance, If I have

import torch
y=torch.randn(10, 480, 640)

How can I convert y to x in pytorch?

Upvotes: 1

Views: 499

Answers (1)

Ivan
Ivan

Reputation: 40698

You can use torch.Tensor.permute:

>>> x = y.permute(2, 0, 1)

Upvotes: 2

Related Questions