TypeError: ‘numpy._DTypeMeta‘ object is not subscriptable
import torch
# 创建一个形状为 (3, 4, 5) 的张量
tensor = torch.randn(3, 4, 5)
# 使用 permute 重新排列维度,例如 (3, 5, 4)
permuted_tensor = tensor.permute(0, 2, 1)
print("Original Tensor Shape:", tensor.shape)
print("Permuted Tensor Shape:", permuted_tensor.shape)
# 在第二个位置添加一个维度,大小为 1 (3, 1, 5, 4)
unsqueezed_tensor = permuted_tensor.unsqueeze(1)
print("Original Permuted Tensor Shape:", permuted_tensor.shape)
print("Unsqueezed Tensor Shape:", unsqueezed_tensor.shape)