PyTorch
torch / torch
torch.transpose¶
-
torch.
transpose
(input, dim0, dim1) → Tensor¶ Returns a tensor that is a transposed version of
input
. The given dimensionsdim0
anddim1
are swapped.The resulting
out
tensor shares it’s underlying storage with theinput
tensor, so changing the content of one would change the content of the other.- Parameters
Example:
>>> x = torch.randn(2, 3) >>> x tensor([[ 1.0028, -0.9893, 0.5809], [-0.1669, 0.7299, 0.4942]]) >>> torch.transpose(x, 0, 1) tensor([[ 1.0028, -0.1669], [-0.9893, 0.7299], [ 0.5809, 0.4942]])
此页内容是否对您有帮助
感谢反馈!