The number of classes is defined by the shape of your model’s output.
E.g. an output of the shape [batch_size, 10] will correspond to 10 different classes.
Try to put an assert statement or any other check inside your training loop to check for invalid values in your target.