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)
x = torch.randn(3, 4)
y = torch.t(x)
print("原始形状:", x.shape)
print("转置后:", y.shape)

Pytorch torch 参考手册