KEMBAR78
[C++ frontend] Add the normalize transform to the core library by goldsborough · Pull Request #15891 · pytorch/pytorch · GitHub
Skip to content

Conversation

@goldsborough
Copy link
Contributor

Adds the Normalize transform to the core C++ frontend library.

@ebetica @ezyang @soumith

@goldsborough goldsborough requested a review from ebetica as a code owner January 9, 2019 21:58
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@soumith soumith added this to the 1.0.1 milestone Jan 15, 2019
@soumith soumith added the cherry-picked This PR was cherry-picked onto a release branch from master label Jan 18, 2019
soumith pushed a commit that referenced this pull request Jan 18, 2019
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
soumith pushed a commit that referenced this pull request Jan 29, 2019
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
@ezyang ezyang added the merged label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked This PR was cherry-picked onto a release branch from master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants