Skip to content
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

Fix test_random_autocontrast flakyness #3699

Merged
merged 7 commits into from
Apr 21, 2021

Conversation

NicolasHug
Copy link
Member

This test is flaky and actually fails in a bunch of random seeds.

Minor differences may happen due to floating point errors. For example with torch.manual_seed(0) you'd get (img - minimum) * scale) equal to 254.999969482421875000000. This will be floored to 254 with the tensors but it's properly set to 255 in PIL. Calling round() doesn't work because the same issue can happen but in PIL instead of torchvision, so the check would still fail on other seeds.

To fix the flakyness we ensure that the max abs difference is no greater than 1, and that such difference happen on less that 5% of the pixels. The new test passes on all seeds in [0, 999]

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@fmassa fmassa merged commit 64b755a into pytorch:master Apr 21, 2021
facebook-github-bot pushed a commit that referenced this pull request May 4, 2021
Summary:
* fix test

* more robust test

* flake8

Reviewed By: NicolasHug

Differential Revision: D28169163

fbshipit-source-id: 1059180968ad3bceff41c48e5c6644461634fdae

Co-authored-by: Francisco Massa <fvsmassa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants