Could you check the target indices and make sure they are in the expected range [0, nb_classes-1]?
Based on the error message the criterion raises the exception as the target values are outside of the valid range.