Skip to content

Fix: eliminate redundant forward pass in evaluate_on_test_set#11

Open
alobroke wants to merge 1 commit intoOrion-AI-Lab:mainfrom
alobroke:fix/eliminate-double-forward-pass
Open

Fix: eliminate redundant forward pass in evaluate_on_test_set#11
alobroke wants to merge 1 commit intoOrion-AI-Lab:mainfrom
alobroke:fix/eliminate-double-forward-pass

Conversation

@alobroke
Copy link
Copy Markdown

What this PR does

Fixes the performance issue reported in #3.

evaluate_on_test_set() was running the model on the full test set
twice — once in its own loop and again inside validate_all().
The all_preds and all_targets collected in the first loop were
never used for metrics.

Changes made

  • Added correct_pixels and total_pixels accumulators to the
    first loop
  • Used extend instead of append to collect flat predictions
    and targets directly
  • Replaced the redundant validate_all() call with a direct call
    to calculate_metrics() using data already collected in the loop
  • Added calculate_metrics to imports from common_metrics

Result

The model now runs on the test set exactly once in all cases,
cutting evaluation time roughly in half.

Related issue

Closes #3

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.

[Performance] evaluate_on_test_set() iterates over the test set twice

1 participant