Could you check the values of your labels?
It should contain class indices in the range [0, nb_classes-1], which is [0, 9],based on your output layer.
Apparently some batches contain label indices outside of this range.