You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
When training the model, an IndexError: Target [X] is out of bounds occurs due to a mismatch between the model’s output dimension (num_classes) and the actual number of classes in the dataset.
Steps to Reproduce
Initialize the model with an incorrect num_classes (e.g., smaller than the maximum label index in the dataset).
Train the model on data where labels exceed the declared num_classes - 1.
Error occurs during loss calculation (e.g., cross-entropy).
Error Message
IndexError: Target [X] isoutofbounds.
# (Full traceback pointing to the loss function)
Expected Behavior
The model should either:
Automatically infer num_classes from the training data.
Throw a clear validation error during initialization if num_classes is misconfigured.
Description
When training the model, an IndexError: Target [X] is out of bounds occurs due to a mismatch between the model’s output dimension (num_classes) and the actual number of classes in the dataset.
Steps to Reproduce
Initialize the model with an incorrect num_classes (e.g., smaller than the maximum label index in the dataset).
Train the model on data where labels exceed the declared num_classes - 1.
Error occurs during loss calculation (e.g., cross-entropy).
Error Message
Expected Behavior
The model should either:
Automatically infer num_classes from the training data.
Throw a clear validation error during initialization if num_classes is misconfigured.