我完全不了解PyTorch,想知道在使用.moveaxis()和.movedim()方法时是否有什么需要注意的。对于相同参数,输出结果是完全相同的。此外,这两种方法都能被.permute()方法替代吗?
以下是一个示例供参考:
import torch
mytensor = torch.randn(3,6,3,1,7,21,4)
t_md = torch.movedim(mytensor, 2, 5)
t_ma = torch.moveaxis(mytensor, 2, 5)
print(t_md.shape, t_ma.shape)
print(torch.allclose(t_md, t_ma))
t_p = torch.permute(mytensor, (0, 1, 3, 4, 5, 2, 6))
print(t_p.shape)
print(torch.allclose(t_md, t_p))