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

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

 通过打印labels和predicted的数据发现,是因为batchsize分批不平均,导致predicted最后有一组只有16个数据。

而range()超过了16,所以报错。

IndexError: index 16 is out of bounds for dimension 0 with size 16_第2张图片

解决办法:1.改变batchsize,使数据集分组刚刚好

                  2.填充最后一组不足的数据 

你可能感兴趣的:(报错,python)