当前位置:   article > 正文

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

runtimeerror: expected floating point type for target with class probabiliti

跑模型的时候发现运行到计算损失函数部分报错。损失函数选择的交叉熵

  1. if use_cuda:
  2. inputs, targets = (inputs[0].cuda(), inputs[1].cuda(), inputs[2].cuda(),
  3. inputs[3].cuda()), targets.cuda()
  4. inputs, targets = (torch.autograd.Variable(inputs[0]), torch.autograd.Variable(inputs[1]),
  5. torch.autograd.Variable(inputs[2]),
  6. torch.autograd.Variable(inputs[3])), torch.autograd.Variable(targets)
  7. outputs = model(inputs)
  8. loss = criterion(outputs, targets) # 出现问题的地方
    声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/649869
    推荐阅读
    相关标签