Skip to content

Remove hardcoded class count assertions to support multiple datasets - #4

Merged
zhulinchng merged 1 commit into
code-simplificationfrom
copilot/sub-pr-2-again
Jan 14, 2026
Merged

zhulinchng merged 1 commit into
code-simplificationfrom
copilot/sub-pr-2-again

Conversation

Copilot AI commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

The validation dataset assertion hardcoded 10 classes, causing failures when training on stanford-dogs (120 classes). The training dataset had a similar hardcoded assertion with a comment indicating support for both 10 and 120 classes, but enforcement didn't match intent.

Changes

  • Remove hardcoded class count assertions for both training and validation datasets
  • Add dynamic validation ensuring training and validation datasets have matching class counts
  • Preserves support for imagenette/woof (10 classes) and stanford-dogs (120 classes)
# Before
assert len(val_dataset.classes) == 10, f"Expected 10 classes, got {len(val_dataset.classes)}"

# After
num_classes = len(train_dataset.classes)
# ... later ...
assert len(val_dataset.classes) == num_classes, (
    f"Training dataset has {num_classes} classes but validation dataset has "
    f"{len(val_dataset.classes)} classes"
)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update to address feedback on formatting and simplification Remove hardcoded class count assertions to support multiple datasets Jan 14, 2026
Copilot AI requested a review from zhulinchng January 14, 2026 01:58
@zhulinchng
zhulinchng marked this pull request as ready for review January 14, 2026 10:38
@zhulinchng
zhulinchng merged commit cf4beb7 into code-simplification Jan 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants