Skip to content

Conversation

@Qin-sx
Copy link
Contributor

@Qin-sx Qin-sx commented Jun 17, 2025

PR Category

User Experience

PR Types

Improvements

Description

当前问题:paddle.nn.SmoothL1Loss和torch.nn.SmoothL1Loss功能不一致。paddle.nn.SmoothL1Loss当前的实现与torch.nn.HuberLoss是一致的。

修改方案
由于目前paddle的SmoothL1Loss与torch的HuberLoss是一致的,因此无法再增加一个HuberLoss来对应SmoothL1Loss,只能在现有基础上改造,增加is_huber参数:

  1. is_huber=True时,与torch.nn.HuberLoss对应。
  2. is_huber=False时,与torch.nn.SmoothL1Loss对应。

默认is_huber=True,保持兼容性升级。

	modified:   python/paddle/nn/functional/loss.py
	modified:   python/paddle/nn/layer/loss.py
	modified:   test/legacy_test/test_smooth_l1_loss.py
@paddle-bot
Copy link

paddle-bot bot commented Jun 17, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 17, 2025
@zhwesky2010 zhwesky2010 changed the title 在smooth_l1_loss函数中加入is_huber参数(仅修改python函数) 在smooth_l1_loss函数中加入is_huber参数 Jun 19, 2025
Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit 0e713e2 into PaddlePaddle:develop Jun 20, 2025
73 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants