-
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][task 224-225] reformat example code with google style in python/paddle/distributed/fleet
#56815
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
>>> # doctest: +SKIP('raise AttributeError') | ||
>>> import paddle | ||
>>> import paddle.distributed.fleet as fleet | ||
>>> fleet.init(is_collective=True) | ||
>>> strategy = fleet.DistributedStrategy() | ||
>>> optimizer = paddle.optimizer.SGD(learning_rate=0.001) | ||
>>> optimizer = fleet.distributed_optimizer(optimizer, strategy=strategy) | ||
|
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.
类似 AttributeError 的错误,如果是示例本身有问题的话,需要尽量修改正确 ~
如果是依赖环境的问题,如 distributed,可以用 REQUIRES ~
如果还是不行,如依赖外部文件等,再用 skip ~
这段示例中,AttributeError 是 SGD 导致的,即便不是 distributed 环境也会出错,所以,需要先修改 SGD 正确:
>>> import paddle
>>> import paddle.distributed.fleet as fleet
>>> fleet.init(is_collective=True)
>>> strategy = fleet.DistributedStrategy()
>>> linear = paddle.nn.Linear(10, 10)
>>> optimizer = paddle.optimizer.SGD(learning_rate=0.001, parameters=linear.parameters())
>>> optimizer = fleet.optimizer.distributed_optimizer(optimizer, strategy=strategy)
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.
多谢耐心指教!已按此修复
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.
LGTM ~
…python/paddle/distributed/fleet` (PaddlePaddle#56815) * [Doctest]fix No.224-225, test=docs_preview * fix the AttributeError
PR types
Others
PR changes
Others
Description