-
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
【PaddlePaddle Hackathon】4、在 Paddle 中新增 RReLU #37067
【PaddlePaddle Hackathon】4、在 Paddle 中新增 RReLU #37067
Conversation
Thanks for your contribution! |
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.
激活函数的op实现方式有点不一样,不是单独文件的形式,可以参考leaky_relu的代码实现改一下。
paddle/fluid/operators/rrelu_op.cc
Outdated
@@ -0,0 +1,158 @@ | |||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. |
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.
2016 -> 2021
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.
收到,已经修改
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.
注意上边还有一条评论,需要比较大的改动,尽快看看吧
python/paddle/nn/layer/activation.py
Outdated
def __init__(self, | ||
lower_bound=0.125, | ||
upper_bound=0.333, | ||
training=True, |
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.
这个training应该是从Layer继承来的,需要框架根据训练、预测自动修改,不能作为参数传入,这样需要手动控制了
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.
收到,已经修改。以前没注意到这点,学习了,谢谢。
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.
@SmirnovKol 这个我之前试感觉不太能用类似leakyRelu的functor来实现,可能要写kernel类
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.
@gsq7474741 leakyRelu中没有随机性,而rrelu对每个X的元素,如果<0, 都要有一个随机的negative_slope,引入了随机性。我觉得可能更应该参考paddle.nn.Dropout的实现。还一个关键点是单元测试时,需要用numpy重新实现一遍rrelu,如何确保用numpy实现和用C++实现,产生的随机的negative_slope是一样的?我还在学习怎么写。
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.
@SmirnovKol 我只前写的思路是先固定随机种子,然后给网络输入一个同尺寸的-1来获取random negative_slope, 然后重置paddle的随机种子,把这个获取的随机斜率给一个np写成的leakyrelu来确保一致性。还有就是我之前在activation.cc/h里面导入GetCPURandomEngine总是编译不过,提示找不到。不知道是什么问题
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.
@gsq7474741 你是这样解决随机性问题的,但是我不知道这样解决是否合适。关于“编译不过”,因为我对C++,感觉还未入门,所以我也不清楚原因在哪。
Sorry to inform you that 852a2de's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
PR types
New features
PR changes
OPs
Describe
在 Paddle 中新增 RReLU