RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel

RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

在高版本的pytorch中,会报这个错误。
例子:

norm_img = transforms.Normalize((10,10,10), (1,1,1))(img)为1
print(norm_img)

报上面错误

解决方案:

对数据进行规范化处理

img=img.float()  #加这一行
norm_img = transforms.Normalize((10,10,10), (1,1,1))(img) 
print(norm_img)

你可能感兴趣的:(报错解决)