Skip to content

Conversation

@zhanghonggeng
Copy link
Contributor

@zhanghonggeng zhanghonggeng commented Aug 6, 2025

PR Category

User Experience

PR Types

New features

Description

增加paddle nn.functional.dropout1d(input, p=0.5, training=True, inplace=False) api
参数:
input (Tensor): 输入张量,形状需为 [C, L] 或 [N, C, L]
p (float): 置零概率(0-1),默认 0.5
training (bool): 是否训练模式,默认 True
inplace (bool): Paddle 暂不支持,仅为兼容 API
WARNING:
当前dropout,dropout1d,dropout2d,dropout3d均不支持inpalce,后续会在dropout中实现dropout_nd C++下沉,同时支持inpacle。
Note:
在 paddle.nn.functional.dropout 中,axis 参数控制 dropout 的应用维度:
当 axis=None(默认值):对输入 Tensor x 中的任意元素,以丢弃概率 p 随机将一些元素输出置 0。
当 axis≠None 时(如 axis=1):以一定的概率从图像特征或语音序列中丢弃掉整个通道。

虽然文档中建议 axis 保持默认值,但这里将 axis 设置为 1 更符合 dropout1d 的含义。
image

pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Aug 6, 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.

@codecov-commenter
Copy link

codecov-commenter commented Aug 6, 2025

Codecov Report

❌ Patch coverage is 12.50000% with 14 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@68835a8). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/nn/functional/common.py 12.50% 14 Missing ⚠️

❌ Your patch status has failed because the patch coverage (12.50%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@ Coverage Diff @@ ## develop #74444 +/- ## ========================================== Coverage ? 12.50% ========================================== Files ? 1 Lines ? 16 Branches ? 0 ========================================== Hits ? 2 Misses ? 14 Partials ? 0 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@zhanghonggeng
Copy link
Contributor Author

/re-run all-failed

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.

看看inplace这个问题,目前yaml里支持了inplace,能否支持一个inplace版本的dropout_接口。inpplace=False时调用dropout,inplace=True时,调用dropout_。

或者通过assign(output)这种能否支持?

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.

assing实现的话可能得充分测下反向,看看与竞品的inplace=True下反向是不是一样

@zhwesky2010
Copy link
Contributor

dropout=0下rtol是不是不用降低

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

@zhwesky2010 zhwesky2010 requested a review from SigureMo August 7, 2025 11:26
@zhanghonggeng
Copy link
Contributor Author

/re-run all-failed

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit dbd453e into PaddlePaddle:develop Aug 8, 2025
97 of 102 checks passed
Enigmatisms pushed a commit to Enigmatisms/Paddle that referenced this pull request Aug 9, 2025
@zhwesky2010 zhwesky2010 changed the title add paddle nn.functional.dropout1d api [API compatibility] add paddle nn.functional.dropout1d api Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment