on_validation_epoch_end() during sanity checking will not run if val-accuracy-interval is greater than max epochs. #1025
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #859
As part of the issue investigation, I tested the initial behavior by creating a dataset with annotations and passing it to the Jupyter notebook. I monkey-patched on_validation_epoch_end() to track and print how often full validation runs and at which epochs. For the test, I set val_accuracy_interval = 30 and max_epochs = 5 (i.e., val_accuracy_interval > max_epochs). As per the documentation, full validation should not run in this case. But it is actually running full validation.

Initally sanity checking happens -

Right after the sanity check, we see on_validation_epoch_end() being called and the complete validation check running -

After training on epoch 0, we see on_validation_epoch_end() being called again and the complete validation check running, since current_epoch is 0 (0 % 30 = 0) -

In the final phase, all epochs trigger on_validation_epoch_end(), but the complete validation check runs only twice—once during sanity checking and once after training when current_epoch = 0 -

All epochs have completed, and the final result is shown below:

All epochs have completed, and the final result is shown below. As expected, complete validation runs four times: during sanity checking, and when current_epoch is 0, 2, and 4

Now, I have modified the code to include a condition that checks if val_accuracy_interval is less than or equal to max_epochs. In this test, val_accuracy_interval = 30 and max_epochs = 5 (i.e., val_accuracy_interval > max_epochs). For this case, we can see that on_validation_epoch_end() is being called, but complete validation is not performed -

In addition to the Jupyter notebook testing, I’ve added
test_validation_interval_greater_than_epochs
intest_main.py
to verify that no full validation metrics are logged whenval_accuracy_interval
(set to 3) is greater thanmax_epochs
(set to 2). The test checks thatbox_precision
,box_recall
, andempty_frame_accuracy
are not present in logged metrics, as full validation is skipped in this case.Note: The case where
val_accuracy_interval
is less than or equal tomax_epochs
is already covered bytest_evaluate_on_epoch_interval
in the same file.Please review and let me know if anything else is needed. Thanks!