-
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
[xdoctest] reformat example code with google style in No.138 and 140 #57479
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
我先改改,先不慌review |
先浅改了一下下,请大佬帮我康康
改完了么? |
可以review了,别的不会改了
…---Original---
From: "Tao ***@***.***>
Date: Tue, Sep 26, 2023 17:47 PM
To: ***@***.***>;
Cc: ***@***.******@***.***>;
Subject: Re: [PaddlePaddle/Paddle] [xdoctest] reformat example code withgoogle style in No.138 and 140 (PR #57479)
我先改改,先不慌review
改完了么?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
python/paddle/tensor/manipulation.py
Outdated
# [[2., 2., 2.], | ||
# [1., 1., 1.], | ||
# [2., 2., 2.]]) | ||
>>> # required: gpu |
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.
改成 doctest 的样式 ~
python/paddle/tensor/manipulation.py
Outdated
# [[2., 1., 2.], | ||
# [2., 1., 2.], | ||
# [2., 1., 2.]]) | ||
>>> # required: gpu |
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.
改成 doctest 的样式 ~
>>> # doctest: +REQUIRES(env:GPU)
python/paddle/tensor/manipulation.py
Outdated
out = paddle.flatten(img, start_axis=1, stop_axis=2) | ||
# out shape is [2, 12, 4] | ||
>>> out = paddle.flatten(img, start_axis=1, stop_axis=2) | ||
>>> # out shape is [2, 12, 4] |
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.
>>> print(out.shape)
[2, 12, 4]
python/paddle/tensor/manipulation.py
Outdated
>>> print(out[0, 0, 0]) | ||
Tensor(shape=[1], dtype=int64, place=Place(cpu), stop_gradient=True, | ||
[-1]) |
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.
已经是 0D 的了
Tensor(shape=[], dtype=int64, place=Place(gpu:0), stop_gradient=True,
-1)
python/paddle/tensor/manipulation.py
Outdated
>>> # the shape of out_2 is [4, 12]. | ||
Tensor(shape=[4, 12], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[[0.16556728, 0.98233348, 0.64653695, 0.68488085, 0.26045629, 0.32933319, | ||
0.29747701, 0.85176629, 0.84460896, 0.86866283, 0.46335083, 0.33930254], | ||
[0.42339125, 0.14102051, 0.69832194, 0.63159829, 0.91087127, 0.31725556, | ||
0.09400324, 0.25861803, 0.26968575, 0.38659596, 0.25225133, 0.26315665], | ||
[0.83726203, 0.33221707, 0.98031831, 0.38393897, 0.00512545, 0.04543629, | ||
0.90596122, 0.70148915, 0.26110184, 0.55263036, 0.68636090, 0.67877120], | ||
[0.60491085, 0.96849394, 0.08488113, 0.48084566, 0.61894107, 0.92885363, | ||
0.37273413, 0.08096626, 0.74429852, 0.85212839, 0.60244918, 0.76718718]]) |
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.
reshape 后的数据不对 ~ x 只是 shape 变了,数据应该不变的 ~
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/tensor/manipulation.py
Outdated
Tensor(shape=[1], dtype=float64, place=Place(cpu), stop_gradient=True, | ||
[285.]) | ||
>>> print(z2) | ||
Tensor(shape=[1], dtype=float64, place=Place(cpu), stop_gradient=True, | ||
[285.]) |
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.
这里 Tensor 是 0D 的 ~
python/paddle/tensor/manipulation.py
Outdated
[[0., 1.], | ||
[4., 5.]] |
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.
这里是 Tensor ~
python/paddle/tensor/manipulation.py
Outdated
>>> print(out1[0, 0, 0]) | ||
[10.] | ||
>>> print(out2[0, 0, 0, 0]) | ||
[10.] | ||
>>> print(out3[0, 0, 0, 0, 0]) | ||
[10.] |
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.
这里是 Tensor ~
python/paddle/tensor/manipulation.py
Outdated
>>> import paddle | ||
>>> paddle.base.set_flags({"FLAGS_use_stride_kernel": True}) | ||
|
||
>>> x = paddle.rand([2, 4, 6], dtype="float32") | ||
|
||
>>> out = paddle.view(x, "uint8") | ||
>>> print(out) |
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.
这里最好也加个 seed 重新看一下结果 ~
python/paddle/tensor/manipulation.py
Outdated
>>> print(out) | ||
Tensor(shape=[8, 6], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[[0.23340422, 0.62036550, 0.12185233, 0.88982582, 0.61383390, 0.22415221], | ||
[0.85698199, 0.87602723, 0.00502827, 0.92127788, 0.34579527, 0.85451263], | ||
[0.68906647, 0.05126054, 0.25322226, 0.43883288, 0.49656981, 0.68857300], | ||
[0.21424839, 0.99576813, 0.62306029, 0.48010525, 0.31222206, 0.48758999], | ||
[0.35929242, 0.12802263, 0.80540675, 0.76783085, 0.84970695, 0.00389719], | ||
[0.69256896, 0.73718327, 0.97155327, 0.50271672, 0.60357946, 0.59580350], | ||
[0.68182445, 0.28539398, 0.13948134, 0.66333318, 0.72601736, 0.31108484], | ||
[0.58283192, 0.89317679, 0.11751470, 0.04111906, 0.04056534, 0.75454420]]) |
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.
这个结果跟 aistudio 上的不一样 ~ 需要确认一下 ~
应该还有一个文件要review@megemini
python/paddle/tensor/manipulation.py
Outdated
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[10.]) | ||
>>> print(out2[0, 0, 0, 0]) | ||
[10.] | ||
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[10.]) | ||
>>> print(out3[0, 0, 0, 0, 0]) | ||
[10.] | ||
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True, | ||
[10.]) |
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.
可以在 aistudio 上面验证一下,安装最新的 develop 版本:
python -m pip install paddlepaddle-gpu==0.0.0.post112 -f https://www.paddlepaddle.org.cn/whl/linux/gpu/develop.html
结果应该是 0D 而不是 1D ~
Sorry to inform you that 512559a's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
[[[[0.01787627, 0.76492310], | ||
[0.67605734, 0.04620579], | ||
[0.38763246, 0.96462214]], | ||
[[0.62356627, 0.64948404], | ||
[0.53736508, 0.09874519], | ||
[0.47123933, 0.85700107]], | ||
[[0.34647217, 0.62869102], | ||
[0.54760450, 0.18061899], | ||
[0.55075216, 0.71997911]], | ||
[[0.78576684, 0.76743823], | ||
[0.35644373, 0.63325852], | ||
[0.26549375, 0.68052763]]], | ||
[[[0.40971112, 0.95848298], | ||
[0.41229674, 0.05506011], | ||
[0.18543524, 0.63480365]], | ||
[[0.81180859, 0.94548297], | ||
[0.19634065, 0.73838711], | ||
[0.42057949, 0.96017945]], | ||
[[0.72278100, 0.93858665], | ||
[0.72018963, 0.61661047], | ||
[0.33307818, 0.86660689]], | ||
[[0.55808324, 0.12933673], | ||
[0.42916751, 0.22745337], | ||
[0.60508877, 0.82193440]]]]) |
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.
这里 reshape 的输出是没有必要的,可以
- 只打印 shape
- 或者使用较小的、arange 数据
下同,其他地方也需要修改
Sorry to inform you that 6820f97's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
close due to the following PR is merged: |
PR types
Others
PR changes
Others
Description
修改如下文件的示例代码,使其通过
xdoctest
检查:python\paddle\tensor\manipulation.py
python\paddle\tensor\search.py
Related links