错误如下 RuntimeError: expected scalar type Double but found Float 原因: tensor的数据类型dtype不正确 解决: 将数据类型转为float32 tensor = tensor.to(torch.float32)