Pytorch BUG 持续填坑

BUG1

在做多分类的时候,计算LOSS 报错:cuda runtime error (59) : device-side assert triggered at /opt/conda/conda-bld/pytorch_1513368888240/work/torch/lib/THC/generated/../THCReduceAll.cuh:33

这是因为 在计算loss的时候 data label 定义出了问题,在用到在用log_softmax +cross_entropy 在做多分类的时候: 损失函数的输入如下:label 序号应该从0 开始 定义。

  • input – Variable (N,C)(N,C) where C = number of classes
  • target – Variable (N)(N) where each value is 0 <= targets[i] <= C-1

解决办法

将目标label 改为从0 开始[1,2,3..20]->[0,1,2...19]

-----------------------------------------------------------------------------------



猜你喜欢

转载自blog.csdn.net/Z_lbj/article/details/80005585