pytorch中,出现的错误:
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
expected scalar type Long but found Float
错误位置:
l = loss(net(X), y) # X是特征Tensor, y是labels_tensor, 计算损失函数,这里出错,y的数据类型不匹配,可以修改数据类型 修改方法: train_labels_tensor = torch.Tensor(train_labels_df.values).to(dtype=torch.int64)标签:labels,匹配,Tensor,torch,数据类型,pytorch,类型,tensor From: https://www.cnblogs.com/xinbigworld/p/17033592.html