pytorch RuntimeError: expected scalar type Double but found Float

RuntimeError: expected scalar type Double but found Float

原因: tensor的数据类型dtype不正确

解决: 将数据类型转为float32

tensor = tensor.to(torch.float32)

 

你可能感兴趣的:(实验室)