解决:IndexError: index 13 is out of bounds for dimension 0 with size 13

解决:IndexError: index 13 is out of bounds for dimension 0 with size 13

    • 报错如下
    • 解决方法

报错如下

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-14-9c4d6dfcfce6> in <module>
     24     for i in range(batch_size):
     25         print(i)
---> 26         label = target.data[i]
     27         class_correct[label] += correct[i].item()
     28         class_total[label] += 1

IndexError: index 13 is out of bounds for dimension 0 with size 13

解决:IndexError: index 13 is out of bounds for dimension 0 with size 13_第1张图片

解决方法

大多数是因为数据样本不均衡,保证数据样本数为batch_size的倍数即可!

你可能感兴趣的:(BUG,python,分类,pytorch)