参考自https://pytorch.org/docs/stable/tensor_attributes.html
tensor的t()属性实现转置
>>> import torch
>>> x = torch.Tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
>>> x
1 2 3 4 5
6 7 8 9 10
[torch.FloatTensor of size 2x5]
>>> x.t()
1 6
2 7
3 8
4 9
5 10
[torch.FloatTensor of size 5x2]
本文介绍在PyTorch中如何使用Tensor的t()属性进行矩阵转置操作,通过示例展示了一个2x5矩阵转置为5x2矩阵的过程。
2580

被折叠的 条评论
为什么被折叠?



