-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Making RandomErasing Out of place by default and improvising tests for the same #1060
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1060 +/- ##
==========================================
- Coverage 63.95% 63.91% -0.04%
==========================================
Files 66 66
Lines 5279 5282 +3
Branches 793 794 +1
==========================================
Hits 3376 3376
- Misses 1672 1674 +2
- Partials 231 232 +1
Continue to review full report at Codecov.
|
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.
Thanks for the PR, having more tests is always better!
I just realized that there is a problem with the current RandomErasing
: it performs the operation in-place. I think that we might want to do it out-of-place, because in-place operations are generally not expected.
Given that RandomErasing has not been in any release yet, I think it's ok to make it out-of-place right away.
Can you update the PR fixing it, and modifying the tests for the new behavior?
test/test_transforms.py
Outdated
# Check if the unerased region is preserved | ||
img_output = F.erase(img, i, j, h, w, v) | ||
erased_region = torch.zeros([3, 60, 60], dtype=torch.float32) | ||
erased_region[:, i:i + h, j:j + w] = v |
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 like erased_region
is all zeros, as v
is zero?
test/test_transforms.py
Outdated
erased_region = torch.zeros([3, 60, 60], dtype=torch.float32) | ||
erased_region[:, i:i + h, j:j + w] = v | ||
|
||
assert torch.equal(img - img_output, erased_region) |
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.
if erased_region
is all zeros, this means that img
is equal to img_output
.
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.
Yep, will change the value in the tests.
@fmassa sure ! will make it out of place. |
@fmassa ready for a review !! |
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.
LGTM, thanks a lot!
This PR includes:
cc: @fmassa