-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -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) |
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.
可以试试两个思路,1. |x| = sqrt(x * x.conj),用这个思路往下推
2. 通过链式法则的方式反推回来 out = x.divide(1+abs(x)), 求dout和dx的关系
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.
请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
第二点用链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样。。。请问有什么方法可以验证一下求导的公式对错吗
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.
- 请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
复数的abs你可以理解为求模,刚好可以等价为sqrt(x*x.conj),可以把这个带入进去求导 - 链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样 。
|x|在复数场景下比较特殊,属于文档中C->R的函数,比较特殊,所以你会发现直接用abs的反向会计算不对,至于怎么验证是否正确,一般能过单测就应该是算对了
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.
- 请问一下第一点是关于|x|的微分公式吗,还是就是x的复数绝对值。
复数的abs你可以理解为求模,刚好可以等价为sqrt(x*x.conj),可以把这个带入进去求导- 链式法则反推,我发现最后的结果还是跟我直接微分的表达式一样 。
|x|在复数场景下比较特殊,属于文档中C->R的函数,比较特殊,所以你会发现直接用abs的反向会计算不对,至于怎么验证是否正确,一般能过单测就应该是算对了
请问一下abs求导的时候要根据sqrt(x*x.conj)这个式子求导吗,一直算出来不对
b0cd1dd
to
6f9cb55
Compare
6f9cb55
to
b7226ca
Compare
@GGBond8488 @luotao1 麻烦review一下,谢谢~ |
重新提个commit触发一下coverage ci 吧 |
#58545 |
PR types
Others
PR changes
OPs
Description
support complex for softsign
#56145