-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[C++ frontend] Add the normalize transform to the core library #15891
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
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.
Question: don't you need to unsqueezr twice if your mean/std is not a scalar, because the batch dimension in the input (4d) is 1?
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.
Correct me if I'm wrong but from https://github.com/pytorch/vision/blob/master/torchvision/transforms/functional.py I figured the user is responsible for passing in the right thing if not a scalar?
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.
The link you pointed has the unsqueeze.
One thing to keep in mind is that torchvision normalize expect one value per channel. Maybe you plan on supporting arbitrary values (which change spatially) here as well?
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.
Hmm so if you pass a two-element tensor as the mean/stddev wouldn't that broadcast correctly over the channels of a two-channel image? At least that's what I test in the tests
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.
Yes, it will.
I think it all boils down to how we represent the images at this point: are they CHW (the torch way) or HWC?
The current implementation works for HWC.
9187f09 to
8117b45
Compare
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.
@goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Adds the `Normalize` transform to the core C++ frontend library. ebetica ezyang soumith Pull Request resolved: #15891 Differential Revision: D13642167 Pulled By: goldsborough fbshipit-source-id: 573428e626d6106cf2aadf3dc2e2aecb9a85efc3
Summary: Adds the `Normalize` transform to the core C++ frontend library. ebetica ezyang soumith Pull Request resolved: #15891 Differential Revision: D13642167 Pulled By: goldsborough fbshipit-source-id: 573428e626d6106cf2aadf3dc2e2aecb9a85efc3
Adds the
Normalizetransform to the core C++ frontend library.@ebetica @ezyang @soumith