RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instea

**RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instead.

使用norm时报错

通过翻译可以知道“输入dtype应为浮点或复杂的dtypes”

代码和错误如下RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instea_第1张图片RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instea_第2张图片

改变一下数据类型即可,即加入“dtype=torch.float”

RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instea_第3张图片
RuntimeError: norm(): input dtype should be either floating point or complex dtypes. Got Long instea_第4张图片

你可能感兴趣的:(pytorch,深度学习,人工智能,python)