By Iris_feng, 29 March, 2024
Forums
Tensor torch.Tensor.item(),只有一个数,获取数值 torch.Tensor.size(),获取维度 torch.Tensor.view(),变换维度 torch.Tensor.permute(),交换维度 GPU device = torch.device("cuda" if torch.cuda.is_available() else "cpu") torch.Tensor.to(device) model.to(device)