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] add test of paddle.nn.ClipGradByValue #228

Merged
merged 13 commits into from Oct 29, 2021

Conversation

simuler
Copy link
Contributor

@simuler simuler commented Oct 10, 2021

PR types

New features

PR changes

APIs

Describe

Task: #35961

add code annotation of paddle.nn.ClipGradByValue

@CLAassistant
Copy link

CLAassistant commented Oct 10, 2021

CLA assistant check
All committers have signed the CLA.

@simuler
Copy link
Contributor Author

simuler commented Oct 11, 2021

PR types

New features

PR changes

添加/framwork/api/nn/test_clip_grad_by_value.py

Describe

Task: #35961

add test of paddle.nn.ClipGradByValue

self.types = [np.float32, np.float64]


obj = TestClipGradByValue(paddle.nn.ClipGradByValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里 obj定义了为什么没有用到呢?

@simuler
Copy link
Contributor Author

simuler commented Oct 11, 2021 via email

@DDDivano
Copy link
Collaborator

您好,请问不定义这个obj可以吗? 另外,unittest和pytest都可以使用吗?

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/PaddleTest" @.>; 发送时间: 2021年10月11日(星期一) 上午10:56 @.>; @.@.>; 主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228) @DDDivano commented on this pull request. In framework/api/nn/test_clip_grad_by_value.py: > + return numpy_data, tensor_data + + +class TestClipGradByValue(APIBase): + """ + test + """ + + def hook(self): + """ + implement + """ + self.types = [np.float32, np.float64] + + +obj = TestClipGradByValue(paddle.nn.ClipGradByValue) 这里 obj定义了为什么没有用到呢? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

可以不使用,不过需要把用不上的代码删掉。unittest和pytest 尽可能使用pytest

@simuler
Copy link
Contributor Author

simuler commented Oct 11, 2021 via email

@simuler
Copy link
Contributor Author

simuler commented Oct 14, 2021

PR types

New features

PR changes

APIs

Describe

Task: #35961

add code annotation of paddle.nn.ClipGradByValue


with pytest.raises(TypeError):
paddle_clip = paddle.nn.ClipGradByValue(clip_max, clip_min)
paddle_clip(paddle_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

增加下min和max相等情况下的case,输入为除了float32和float64外其他类型的case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

你好,已经增加min和max相等的case,输入为float16类型的case


with pytest.raises(AssertionError):
paddle_clip = paddle.nn.ClipGradByValue(clip_max, clip_min)
paddle_clip(paddle_data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

处理异常时校验下框架抛出的异常信息,在不同异常下抛出的是不同的,这个需要校验下

@simuler
Copy link
Contributor Author

simuler commented Oct 20, 2021 via email

@kolinwei
Copy link
Collaborator

不好意思,麻烦您可以详细说明一下 这个捕获异常部分的代码具体什么问题吗? 源码当中遇到这种情况是报的AssertionError。

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/PaddleTest" @.>; 发送时间: 2021年10月19日(星期二) 上午10:18 @.>; @.@.>; 主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228) @kolinwei requested changes on this pull request. In framework/api/nn/test_clip_grad_by_value.py: > + clip_min = None + clip_max = 1.0 + Changes: + clip_max: 1.0 -> -1.0 + Expected Results: + The output of ClipGradByValue implemented by numpy and paddle should be equal. + """ + shape = [10, 10] + length = 4 + clip_min = None + clip_max = -1.0 + np_data, paddle_data = generate_test_data(length, shape) + + with pytest.raises(AssertionError): + paddle_clip = paddle.nn.ClipGradByValue(clip_max, clip_min) + paddle_clip(paddle_data) 处理异常时校验下框架抛出的异常信息,在不同异常下抛出的是不同的,这个需要校验下 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

可以参考#223

@simuler
Copy link
Contributor Author

simuler commented Oct 22, 2021 via email

@simuler
Copy link
Contributor Author

simuler commented Oct 25, 2021 via email

@kolinwei
Copy link
Collaborator

我看不到你发的图,具体是什么问题呢

@simuler
Copy link
Contributor Author

simuler commented Oct 27, 2021 via email

@kolinwei
Copy link
Collaborator

paddle.nn.ClipGradByvalu

换个其他的异常输入呢,不应该是空格呀

@simuler
Copy link
Contributor Author

simuler commented Oct 28, 2021 via email

@DDDivano DDDivano merged commit ee44667 into PaddlePaddle:develop Oct 29, 2021
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.

None yet

4 participants