PyTorch常见error

1.RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes' failed.  at c:\programdata\miniconda3\conda-bld\pytorch-cpu_1532498166916\work\aten\src\thnn\generic/ClassNLLCriterion.c:93

PyTorch训练时的下角标必须从“0”开始,否则报错;

2.

仅剩一个样本时会报此错误,可在DataLoader函数中添加drop_last=True;

3.

RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'mat2'(期望对象为标量类型长,但得到标量类型浮点数)

x=x.float();

在labels变成labels.long()即可解决此错误
 

 

 

 

 

 

 

你可能感兴趣的:(PyTorch)