-
Notifications
You must be signed in to change notification settings - Fork 117
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
Conversation
|
self.types = [np.float32, np.float64] | ||
|
||
|
||
obj = TestClipGradByValue(paddle.nn.ClipGradByValue) |
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.
这里 obj定义了为什么没有用到呢?
您好,请问不定义这个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 |
收到,非常感谢!
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleTest" ***@***.***>;
发送时间: 2021年10月11日(星期一) 中午1:10
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228)
您好,请问不定义这个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
—
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.
|
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) |
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.
增加下min和max相等情况下的case,输入为除了float32和float64外其他类型的case
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.
你好,已经增加min和max相等的case,输入为float16类型的case
|
||
with pytest.raises(AssertionError): | ||
paddle_clip = paddle.nn.ClipGradByValue(clip_max, clip_min) | ||
paddle_clip(paddle_data) |
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.
处理异常时校验下框架抛出的异常信息,在不同异常下抛出的是不同的,这个需要校验下
不好意思,麻烦您可以详细说明一下
这个捕获异常部分的代码具体什么问题吗?
源码当中遇到这种情况是报的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 |
你好,我参考#223捕获了所有Exception
打印捕获到的异常如下图所示,麻烦可以看下什么情况吗?
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleTest" ***@***.***>;
发送时间: 2021年10月21日(星期四) 晚上8:30
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228)
不好意思,麻烦您可以详细说明一下 这个捕获异常部分的代码具体什么问题吗? 源码当中遇到这种情况是报的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
—
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捕获了所有Exception
代码和打印捕获到的异常如下图所示,麻烦可以看下什么情况吗?
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleTest" ***@***.***>;
发送时间: 2021年10月21日(星期四) 晚上8:30
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228)
不好意思,麻烦您可以详细说明一下 这个捕获异常部分的代码具体什么问题吗? 源码当中遇到这种情况是报的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
—
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.
|
我看不到你发的图,具体是什么问题呢 |
我运行以下代码,打印出来什么也没有
try:
clip1 = paddle.nn.ClipGradByvalue(max= -1)
except Exception as e1:
print('except1:',e1)
打印出来是空格,什么也没有,就像下面
except1:
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleTest" ***@***.***>;
发送时间: 2021年10月27日(星期三) 中午11:23
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228)
我看不到你发的图,具体是什么问题呢
—
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.
|
换个其他的异常输入呢,不应该是空格呀 |
这是捕捉两个异常的情况
try:
clip1 = paddle.nn.ClipGradByvalue(max= -1)
except Exception as e1:
print('except1:',e1)
try:
clip2 = paddle.nn.ClipGradByValue(max='1')
except Exception as e2:
print('except2:',e2)
打印出来第一个是空格,第二个是错误
except1:
except2: '>' not supported between instance of 'str' and 'float'
…------------------ 原始邮件 ------------------
发件人: "PaddlePaddle/PaddleTest" ***@***.***>;
发送时间: 2021年10月28日(星期四) 晚上10:05
***@***.***>;
***@***.******@***.***>;
主题: Re: [PaddlePaddle/PaddleTest] [PaddlePaddle hackathon] add test of paddle.nn.ClipGradByValue (#228)
paddle.nn.ClipGradByvalu
换个其他的异常输入呢,不应该是空格呀
—
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.
|
PR types
New features
PR changes
APIs
Describe
Task: #35961
add code annotation of paddle.nn.ClipGradByValue