Hi, in tensorflow, we have
data_format option in
tf.nn.conv2d which could specify the data format as
Is there equivalent operation in pytorch?
If not, should we convert
np.swapaxes and convert it back into
And under such circumstances, will the gradient tracked properly?
No, we only support
NCHW format. You can use
.permute to swap the axis.
Thanks, I have just checked the Docs, but it seems that I just miss it…
@Veril transpose only applies to 2 axis, while permute can be applied to all the axes at the same time.
a = torch.rand(1,2,3,4)
permute internally calls
transpose a number of times
Indeed, it can be a shortcut to use
tensor = tensor.transpose(0, 1)
But note that the difference in performance is not significant, as
transpose does not copy memory nor allocate new memory, and only swaps the strides.
Awesome method! Why not combine
transpose or make
transpose inaccessible to user since it’s used internally by
permute as mentioned by fmassa.