Skip to content

ENH Adds label_smoothing to cross entropy loss#63122

Closed
thomasjpfan wants to merge 43 commits into
pytorch:masterfrom
thomasjpfan:smooth_cross_entropy
Closed

ENH Adds label_smoothing to cross entropy loss#63122
thomasjpfan wants to merge 43 commits into
pytorch:masterfrom
thomasjpfan:smooth_cross_entropy

Conversation

@thomasjpfan

@thomasjpfan thomasjpfan commented Aug 12, 2021

Copy link
Copy Markdown
Contributor

@thomasjpfan thomasjpfan added module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Aug 12, 2021
@facebook-github-bot

facebook-github-bot commented Aug 12, 2021

Copy link
Copy Markdown
Contributor

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 1a41ce5 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@thomasjpfan thomasjpfan changed the title ENH Adds label_smoothing to targets as class indices ENH Adds label_smoothing to targets as class indices in cross_entropy Aug 12, 2021
Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
@ezyang
ezyang removed their request for review August 12, 2021 13:49
@albanD
albanD removed their request for review August 12, 2021 15:03
@jbschlosser
jbschlosser requested a review from zou3519 August 12, 2021 17:44

@jbschlosser jbschlosser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for tackling this! Added some comments below. To summarize:

  • I think we want the end result to handle both ignore_index and class prob targets
  • Can the implementation be simplified by doing label smoothing as additional math outside of the call to at::nll_loss_nd and doing a linear combination?

Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
Comment thread torch/nn/modules/loss.py Outdated
Comment thread test/test_nn.py
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@jbschlosser has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@jbschlosser jbschlosser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread aten/src/ATen/native/LossNLL.cpp Outdated
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@datumbox has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread torch/onnx/symbolic_opset12.py
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@datumbox has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@jbschlosser has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@codecov

codecov Bot commented Aug 28, 2021

Copy link
Copy Markdown

Codecov Report

Merging #63122 (1a41ce5) into master (3abb606) will increase coverage by 0.00%.
The diff coverage is 88.88%.

@@           Coverage Diff           @@
##           master   #63122   +/-   ##
=======================================
  Coverage   66.73%   66.74%           
=======================================
  Files         698      698           
  Lines       90892    90922   +30     
=======================================
+ Hits        60661    60690   +29     
- Misses      30231    30232    +1     

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@jbschlosser merged this pull request in d3bcba5.

jbschlosser added a commit to jbschlosser/nestedtensor that referenced this pull request Sep 2, 2021
Summary:
Adds awareness of the new `label_smoothing` functionality in `cross_entropy` added in pytorch/pytorch#63122 to nestedtensor's implementation.

Fixes broken test: `test.test_nested_tensor_functional.TestFunctional`.

Differential Revision: D30730728

fbshipit-source-id: 34d907b76a1d2058cc7bc7d12c271cc3088a351b
facebook-github-bot pushed a commit to pytorch/nestedtensor that referenced this pull request Sep 2, 2021
Summary:
Pull Request resolved: #452

Adds awareness of the new `label_smoothing` functionality in `cross_entropy` added in pytorch/pytorch#63122 to nestedtensor's implementation.

Fixes broken test: `test.test_nested_tensor_functional.TestFunctional`.

Reviewed By: cpuhrsch

Differential Revision: D30730728

fbshipit-source-id: 04f146d6de7f764f165059e4b5654d7f39142e38
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 25, 2026
Summary:
Fixes pytorch#7455

Partially resolves pytorch/vision#4281

Pull Request resolved: pytorch#63122

Reviewed By: iramazanli

Differential Revision: D30586076

Pulled By: jbschlosser

fbshipit-source-id: 06afc3aa1f8b9edb07fe9ed68c58968ad1926924
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: nn Related to torch.nn open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update reference scripts to use the "Batteries Included" utils [PyTorch][Feature Request] Label Smoothing for CrossEntropyLoss

7 participants