Skip to content
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

【complex】 No.32 support complex for softsign #57552

Closed
wants to merge 1 commit into from

Conversation

xiaoyewww
Copy link
Contributor

PR types

Others

PR changes

OPs

Description

support complex for softsign
#56145

@paddle-bot
Copy link

paddle-bot bot commented Sep 20, 2023

你的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 Sep 20, 2023
@@ -2078,6 +2078,30 @@ struct SoftsignGradFunctor : public BaseActivationFunctor<T> {
static constexpr ActBwdOpFwdDeps FwdDeps() { return ActBwdOpFwdDeps::kDepX; }
};

// x = a+bi
// |x| = r = sqrt(a^2 + b^2)
Copy link
Contributor

@GGBond8488 GGBond8488 Sep 21, 2023

Choose a reason for hiding this comment

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

可以试试两个思路,1. |x| = sqrt(x * x.conj),用这个思路往下推
2. 通过链式法则的方式反推回来 out = x.divide(1+abs(x)), 求dout和dx的关系

Copy link
Contributor Author

@xiaoyewww xiaoyewww Sep 22, 2023

Choose a reason for hiding this comment

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

请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
第二点用链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样。。。请问有什么方法可以验证一下求导的公式对错吗

Copy link
Contributor

@GGBond8488 GGBond8488 Sep 25, 2023

Choose a reason for hiding this comment

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

  1. 请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
    复数的abs你可以理解为求模,刚好可以等价为sqrt(x*x.conj),可以把这个带入进去求导
  2. 链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样 。
    |x|在复数场景下比较特殊,属于文档中C->R的函数,比较特殊,所以你会发现直接用abs的反向会计算不对,至于怎么验证是否正确,一般能过单测就应该是算对了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. 请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
    复数的abs你可以理解为求模,刚好可以等价为sqrt(x*x.conj),可以把这个带入进去求导
  2. 链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样 。
    |x|在复数场景下比较特殊,属于文档中C->R的函数,比较特殊,所以你会发现直接用abs的反向会计算不对,至于怎么验证是否正确,一般能过单测就应该是算对了

请问一下abs求导的时候要根据sqrt(x*x.conj)这个式子求导吗,一直算出来不对

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Sep 21, 2023
@luotao1 luotao1 added HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 and removed HappyOpenSource 快乐开源活动issue与PR labels Sep 22, 2023
@xiaoyewww xiaoyewww force-pushed the feat/softsign branch 3 times, most recently from b0cd1dd to 6f9cb55 Compare October 30, 2023 16:31
@xiaoyewww
Copy link
Contributor Author

@GGBond8488 @luotao1 麻烦review一下,谢谢~

@GGBond8488
Copy link
Contributor

重新提个commit触发一下coverage ci 吧

@xiaoyewww xiaoyewww closed this Oct 31, 2023
@xiaoyewww
Copy link
Contributor Author

重新提个commit触发一下coverage ci 吧

#58545
@GGBond8488 佬,已经重新提交

@xiaoyewww xiaoyewww deleted the feat/softsign branch May 10, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants