Skip to content Skip to sidebar Skip to footer

How Can I Swap Axis In A Torch Tensor?

I have a torch tensor of size torch.Size([1, 128, 56, 128]) 1 is channel, 128 is the width, and height. 56 are the stacks of images. How can I resize it to torch.Size([1, 56, 128,

Solution 1:

You could simply use permute or transpose.

Solution 2:

You can use the swapaxes function:

my_tensor.swapaxes(1,2)

Post a Comment for "How Can I Swap Axis In A Torch Tensor?"