PyTorch torch.t 函数

约 194 字 更新于 2026-11-18 5iyo.com

PyTorch torch.t 函数


torch.t 是 PyTorch 中用于二维张量转置的函数。

函数定义

torch.t(input)

使用示例

实例

import torch

x = torch.randn(3, 4)

y = torch.t(x)

print("原始形状:", x.shape)
print("转置后:", y.shape)