-
Notifications
You must be signed in to change notification settings - Fork 26.3k
combine size_average and reduce args in loss functions #8018
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
|
I can see why we might want to change the C code, but do we really think that breaking backward compatibility to make people say |
|
In Python-land, maybe "reduce=None" should default to |
|
This current version won't break backwards compatibility, but I was planning to stop supporting it in a future version. A couple motivators behind this change:
|
|
One more random idea: deprecate |
|
I really don't think that using enums is very user friendly. It's definitely more verbose, and very rare in Python APIs. What's the issue with the two boolean flags we have right now? Sure, there are configurations which are incompatible, but assuming we keep our current defaults, you only specify at most one of those two arguments, and no issues should arise. |
|
I think there is value removing both boolean flags and keeping only a single one. I also agree that enum is not very pythonic: what about having strings instead? |
|
We also want to add support for different types of averaging (dividing by batch_size instead of number of elements). Under the current scheme the only way to do that is to add a third boolean argument, which again, will only be valid if the others are in certain configurations. I think combining the arguments makes a lot of sense if we look at the perspective of a user: Most people are going to be looking at the documentation before using any of these functions, and I think the documentation would be a simpler to understand if all these similar functionalities were under a single argument. |
|
I definitely have been confused by what certain combination would do, so at least in the front of making the behavior clearer to users, this certainly helps. That said, enum indeed isn't really used in Python API, as @apaszke said. A more common pattern is to directly use strings, as we are already doing in |
|
Strings aren’t ideal, but they’re better than enums. I would be ok with that |
|
Roy, could you change the codegen so that we have a way to map between c++
enum and Python strings? I would love to see such a change :)
…On Wed, Jun 6, 2018 at 03:48 Adam Paszke ***@***.***> wrote:
Strings aren’t ideal, but they’re better than enums. I would be ok with
that
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8018 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFaWZYqU6UdNXnaBryrtVERgZQWt23Haks5t54lVgaJpZM4UWAfl>
.
|
|
@pytorchbot retest this please |
|
@pytorchbot retest this please |
1 similar comment
|
@pytorchbot retest this please |
ssnl
left a comment
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.
I added a few general questions and comments to understand the general goal of this PR. After they are resolved I can make a detailed pass.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/ATen/nn.yaml
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
Please fix tests and rebase too |
4cfb9a7 to
2bec94f
Compare
|
@pytorchbot retest this please |
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
aten/src/THNN/Reduction.h
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
torch/nn/functional.py
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
@pytorchbot retest this please |
ssnl
left a comment
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.
Code looks great. Please prefix the enum class with _. Thanks!
|
@ssnl You're talking about Reduction in nn/functional.py, right? Should that still be prefixed if I'm using it in other files as well? |
|
@li-roy yes, because that's not part of public api. In other words, it shouldn't show up in user's IDE code autocompletion. |
|
@ssnl Oh that makes sense now, thanks for the explanation. |
|
Sorry for not being clear earlier.
…On Wed, Jun 27, 2018 at 19:18 li-roy ***@***.***> wrote:
@ssnl <https://github.com/SsnL> Oh that makes sense now, thanks for the
explanation.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8018 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AFaWZTv7siLU7Sh1eeF80mZ2JzxcrgTjks5uBBLBgaJpZM4UWAfl>
.
|
|
btw, if you haven't, you should rebase & import to phabricator. |
facebook-github-bot
left a comment
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.
@li-roy has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@li-roy has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@li-roy is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@li-roy is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
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.
@li-roy is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: closes #7929 Closes pytorch/pytorch#8018 Differential Revision: D8682540 Pulled By: li-roy fbshipit-source-id: 649170dd1a7f373151c1d4e949838bd1c5651936
Summary: closes #7929 Closes pytorch/pytorch#8018 Differential Revision: D8682540 Pulled By: li-roy fbshipit-source-id: 649170dd1a7f373151c1d4e949838bd1c5651936
Summary: closes pytorch#7929 Closes pytorch#8018 Differential Revision: D8682540 Pulled By: li-roy fbshipit-source-id: 649170dd1a7f373151c1d4e949838bd1c5651936
Summary: Currently one of our GPU perf tests `test_gpu_speed_mnist` reports NaN after this commit (#8018), and we didn't have the logic in place to raise error when this happens. This PR fixes the problem and will also update the baseline properly even if its previous value is NaN. Pull Request resolved: #11588 Differential Revision: D9831798 Pulled By: yf225 fbshipit-source-id: b95eee38d69b3b8273f48b8ac7b7e0e79cf756ed
closes #7929