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

【PaddlePaddle Hackathon】4、在 Paddle 中新增 RReLU #37067

Closed
wants to merge 9 commits into from
Closed

【PaddlePaddle Hackathon】4、在 Paddle 中新增 RReLU #37067

wants to merge 9 commits into from

Conversation

OccupyMars2025
Copy link
Contributor

PR types

New features

PR changes

OPs

Describe

在 Paddle 中新增 RReLU

@paddle-bot-old
Copy link

paddle-bot-old bot commented Nov 9, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@zhiboniu zhiboniu left a comment

Choose a reason for hiding this comment

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

激活函数的op实现方式有点不一样,不是单独文件的形式,可以参考leaky_relu的代码实现改一下。

@@ -0,0 +1,158 @@
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2016 -> 2021

Copy link
Contributor Author

Choose a reason for hiding this comment

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

收到,已经修改

Copy link
Contributor

Choose a reason for hiding this comment

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

注意上边还有一条评论,需要比较大的改动,尽快看看吧

def __init__(self,
lower_bound=0.125,
upper_bound=0.333,
training=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个training应该是从Layer继承来的,需要框架根据训练、预测自动修改,不能作为参数传入,这样需要手动控制了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

收到,已经修改。以前没注意到这点,学习了,谢谢。

Copy link
Contributor

@gsq7474741 gsq7474741 Nov 11, 2021

Choose a reason for hiding this comment

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

@SmirnovKol 这个我之前试感觉不太能用类似leakyRelu的functor来实现,可能要写kernel类

Copy link
Contributor Author

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是一样的?我还在学习怎么写。

Copy link
Contributor

@gsq7474741 gsq7474741 Nov 12, 2021

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总是编译不过,提示找不到。不知道是什么问题

Copy link
Contributor Author

@OccupyMars2025 OccupyMars2025 Nov 13, 2021

Choose a reason for hiding this comment

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

@gsq7474741 你是这样解决随机性问题的,但是我不知道这样解决是否合适。关于“编译不过”,因为我对C++,感觉还未入门,所以我也不清楚原因在哪。

@paddle-bot-old
Copy link

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.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants