【发布时间】:2021-09-03 14:07:47
【问题描述】:
我对 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))
【问题讨论】: