Pytorch之permute函数
1 先看看官方中英文doc:
torch.Tensor.permute (Python method, in torch.Tensor)
1.1 permute(dims)
将tensor的维度换位。
参数: - dims (int …*) - 换位顺序
例:
>>> x = torch.randn(2, 3, 5)
>>> x.size()
torch.Size([2, 3, 5])
>>> x.permute(2, 0, 1).size()
torch.Size([5, 2, 3])
2 pytorch permute的使用
permute函数功能还是比较简单的,下面主要介绍几个细节点:
2.1 transpose与permute的异同
Tensor.permute(a,b,c,d, …):permute函数可以对任意高维矩阵进行转置,但没有 torch.permute() 这个调用方式, 只能 Tensor.permute():
>>> torch.randn(

最低0.47元/天 解锁文章
1965





