[RuntimeError] Expected floating point type for target with class probabilities, got Long

[RuntimeError] Expected floating point type for target with class probabilities, got Long_第1张图片
这个报错类型翻译过来就是:有类别概率的目标的预期浮点类型,得 Long
大概意思就是你输入的标签值是浮点数,但实际上你所获得的是Long类型的值
原代码

Train_L = torch.tensor(expect_output,dtype=torch.int64)   # int64
label = Variable(Train_L)

解决方法

Train_L = torch.tensor(expect_output,dtype=torch.int64)   # int64
label = Variable(Train_L).float()

你可能感兴趣的:(Python学习中遇到的小错误,pytorch,深度学习,人工智能)