官方文档:https://pytorch.org/docs/stable/generated/torch.permute.html?highlight=torch%20permute#torch.permute
形式:torch.permute(input, dims) → Tensor
作用:返回原始张量输入的视图,其尺寸已置换。
参数:
- input (Tensor) – the input tensor.
- dims (tuple of python:ints) – The desired ordering of dimensions
使用案例:
x = torch.randn(2, 3, 5)
x.size() # torch.Size([2, 3, 5])
torch.permute(x, (2, 0, 1)).size() # torch.Size([5, 2, 3])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)