-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure deterministic in MixUp, CutMix, CutOut #7813
Conversation
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
/build |
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, the test changes look good too and capture the actual semantics we want. Thanks!
/build |
Fixes Project-MONAI#7697 ### Description A few sentences describing the changes proposed in this pull request. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
def __call__(self, data: torch.Tensor, labels: torch.Tensor | None = None): | ||
self.randomize() | ||
augmented = self.apply(data) | ||
return (augmented, self.apply_on_labels(labels)) if labels is not None else augmented | ||
def __call__(self, data: torch.Tensor, labels: torch.Tensor | None = None, randomize=True): | ||
data = convert_to_tensor(data, track_meta=get_track_meta()) | ||
data_t = convert_to_tensor(data, track_meta=False) | ||
if labels is not None: | ||
labels_t = convert_to_tensor(labels, track_meta=get_track_meta()) | ||
labels_t = convert_to_tensor(labels, track_meta=False) | ||
if randomize: | ||
self.randomize(data) | ||
augmented = convert_to_dst_type(self.apply(data_t), dst=data)[0] | ||
if labels is not None: | ||
augmented_label = convert_to_dst_type(self.apply(labels_t), dst=labels)[0] | ||
return (augmented, augmented_label) if labels is not None else augmented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I'm a researcher currently working with CutMix and other similar method. My group and I noticed an inconsistent behavior in CutMix on the segmentation labels on our different machines. After some digging, we think it may come from this PR: before this change, self.apply_on_labels(labels)
is used for the label, but the modified change use self.apply(labels_t)
which uses the same cropping mechanism as for the image.
This PR does not mention the reason for this change, could you enlighten me please ?
Thank you in advance for your time.
Fixes #7697
Description
A few sentences describing the changes proposed in this pull request.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.