-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[xdoctest] reformat example code with google style No.80-85 #55806
The head ref may contain hidden characters: "\u5F15\u5165xdoctest\u68C0\u67E580-85"
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
#55811 已经合入,精度问题应该是可以解决了,需要 merge 一下 develop 试一下 不过看样子还有些非精度问题,也需要看一下 |
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/layers.py
Outdated
... | ||
>>> model = Model() | ||
>>> model.float16() | ||
>>> #UserWarning: Paddle compiled by the user does not support float16, so keep original data type. |
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
# [-1.25, 6. , 7. , -2. ], | ||
# [ 6. , 7. , 8. , 9. ]]]] | ||
>>> import paddle | ||
>>> paddle.set_default_dtype("float64") |
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.
日志里fail的,应该都是这个导致的:
2023-08-02 11:44:04 14 sample codes ran failed
2023-08-02 11:44:04 <DocTest(<modname?> paddle.DataParallel.float16:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.DataParallel.to:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.ReLU:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.ReLU6:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.SELU:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Sigmoid:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Silu:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Softmax2D:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Softshrink:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Softsign:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Swish:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Tanh:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.Tanhshrink:1:0 ln 1)>
2023-08-02 11:44:04 <DocTest(<modname?> paddle.nn.ThresholdedReLU:1:0 ln 1)>
可以尝试在本地用 convert-doctest doctest 测试一下~
这里 paddle.set_default_dtype("float64")
导致后续都是以 float64 进行计算,从而与结果比对出错~
我在本地把 paddle.set_default_dtype("float64")
这行去掉可以过测~
建议把这行删掉,感觉没什么必要,PRelu 对精度也没什么特殊的要求~
@SigureMo 请帮忙看看~
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.
这里
paddle.set_default_dtype("float64")
导致后续都是以 float64 进行计算,从而与结果比对出错~
是说一个示例代码的运行会影响其他示例代码?这会不会有点问题啊,比如之后可能有些 API 会 enable_static,那其他 API 会受到影响的
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.
嗯,确实有!
xdoctest 的 doctest_example.py 你可以看一下~
它有一个 global_namespace
跟踪命名空间,每次执行测试都是先 _test_globals
获取全局变量,它自己也说 unclear side effects
每次执行后都有 self.global_namespace.clear()
防止 leak memory~
CI 的执行应该是按照字母排名的,导致 PRelu 之后的这些都 fail 了~
解决办法,xdoctest 有个 global_exec
目前的设置是:
XDOCTEST_CONFIG = {
"global_exec": r"\n".join(
[
"import paddle",
"paddle.device.set_device('cpu')",
]
),
"default_runtime_state": {"IGNORE_WHITESPACE": True},
}
我觉得后面可以加个 set_default_dtype
disable_static
之类的~
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.
是说一个示例代码的运行会影响其他示例代码?这会不会有点问题啊,比如之后可能有些 API 会 enable_static,那其他 API 会受到影响的
嗯,更新一下 Xdoctester
的 global_exec
加上 set_default_dtype
disable_static
之类的吧 ~
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.
LGTMeow
PR types
Others
PR changes
Others
Description
修改如下文件的示例代码,使其通过
xdoctest
检查:预览:
存在的问题:
比如GELU()的结果精度存在差异:
-0.15865529 和 -0.15865526,暂时等待解决办法
关联 PR:
#55629
#55295
@sunzhongkai588 @SigureMo @megemini