Feature: Select validation in evenly spaced blocks#949
Open
melisande-c wants to merge 13 commits into
Open
Conversation
Member
Author
jdeschamps
approved these changes
May 19, 2026
Member
jdeschamps
left a comment
There was a problem hiding this comment.
I did not have time to delve too much in the details, but looks good.
Let's improve the error message as mentioned in the chat, and see the benchmark results.
| for j in range(ndims) | ||
| if i != j and val_coords_1D[j] is None | ||
| ] | ||
| # remaining val patches for the dimensions not calculate yet |
Member
There was a problem hiding this comment.
Suggested change
| # remaining val patches for the dimensions not calculate yet | |
| # remaining val patches for the dimensions not calculated yet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Disclaimer
Description
Note
tldr: Randomly selecting validation patches could result in a configuration that reduces the likelyhood of some regions being selected for training. Additionally the validation might not accurately represent the statistics of the data.
Background - why do we need this PR?
For smallish image sizes selecting the validation patches badly could result in a reduction in the probability that some regions are selected for validation. This happens when the validation patches are too close too each other or the edge, making it unlikely to select the region between the validation patches for training.
Overview - what changed?
Added validation selection functionality that groups validation patches together in evenly spaced blocks so that there is always a gap greater than two patch widths between validation blocks, (and between the edges of the image and the blocks).
If this results in too many patches then validation patches are randomly removed, only if there removal does not result in a gap of 1, until the desired number of validation patches.
Implementation - how did you implement the changes?
Changes Made
New features or files
select_validationfunction + helper functionsModified features or files
create_val_splitfunction -> replaced random val selection with block val selectionHow has this been tested?
Related Issues
Additional Notes and Examples
The included demo script produces the following results:
You can see how the random validation selection is effectively reducing the training data for the larger percentages of validation.
The new validation patch selection

The previous random validation selection

Please ensure your PR meets the following requirements: