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

[xdoctest][task 224-225] reformat example code with google style in python/paddle/distributed/fleet #56815

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

jinyouzhi
Copy link
Contributor

@jinyouzhi jinyouzhi commented Aug 30, 2023

@paddle-bot
Copy link

paddle-bot bot commented Aug 30, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Aug 30, 2023
@jinyouzhi
Copy link
Contributor Author

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 31, 2023
Comment on lines 41 to 48
>>> # 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)

Copy link
Contributor

@megemini megemini Sep 1, 2023

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

多谢耐心指教!已按此修复

Copy link
Contributor

@megemini megemini left a comment

Choose a reason for hiding this comment

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

LGTM ~

@luotao1 luotao1 merged commit 53d0869 into PaddlePaddle:develop Sep 5, 2023
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
…python/paddle/distributed/fleet` (PaddlePaddle#56815)

* [Doctest]fix No.224-225, test=docs_preview

* fix the AttributeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants