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

[Docathon][Fix COPY-FROM No.11-15] #6310

Closed
wants to merge 12 commits into from
Closed

[Docathon][Fix COPY-FROM No.11-15] #6310

wants to merge 12 commits into from

Conversation

Turingg
Copy link
Contributor

@Turingg Turingg commented Nov 12, 2023

PR types
Bug fixes

PR changes
Docs

Description
Issue from:#6300 中文文档 copy-from 清理
涉及到的API有:
paddle.distributed.fleet.Fleet
paddle.optimizer.Adadelta
paddle.optimizer.AdamW
paddle.optimizer.Adam
paddle.optimizer.Adamax
以上文档中部分.. code-block:: python 之后没有空行 (在不需要 name: code_id 标识符时):添加空行

@ooooo-create @sunzhongkai588

Copy link

paddle-bot bot commented Nov 12, 2023

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6310.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

@CLAassistant
Copy link

CLAassistant commented Nov 12, 2023

CLA assistant check
All committers have signed the CLA.

把 ..code-block 删了改成copyfrom的形式
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Nov 13, 2023
Copy link
Collaborator

@ooooo-create ooooo-create left a comment

Choose a reason for hiding this comment

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

赞!还有一些问题需要改一改~

@@ -29,29 +29,29 @@ None

**代码示例 1**

.. code-block:: python
COPY-FROM: paddle.distributed.fleet.Fleet
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里是属于 init 函数叭,改成COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1,后面类似~。
参考 下面的
https://github.com/PaddlePaddle/Paddle/blob/816b34e729568fc244a7ac205df9d140f59a5ac0/python/paddle/distributed/fleet/fleet.py#L203C1-L207C33

同时,删除 .. code-block:: python 的时候也把下面的代码顺带一起删了~


import paddle.distributed.fleet as fleet
fleet.init()

**代码示例 2**

.. code-block:: python
COPY-FROM: paddle.distributed.fleet.Fleet
Copy link
Collaborator

Choose a reason for hiding this comment

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

上同


import paddle.distributed.fleet as fleet
fleet.init(is_collective=True)

**代码示例 3**

.. code-block:: python
COPY-FROM: paddle.distributed.fleet.Fleet
Copy link
Collaborator

Choose a reason for hiding this comment

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

上同


import paddle.distributed.fleet as fleet
role = fleet.PaddleCloudRoleMaker()
fleet.init(role)

**代码示例 4**

.. code-block:: python
COPY-FROM: paddle.distributed.fleet.Fleet
Copy link
Collaborator

Choose a reason for hiding this comment

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

上同

@@ -485,8 +485,7 @@ distributed_model(model)

**代码示例**

.. code-block:: python

COPY-FROM: paddle.distributed.fleet.Fleet.distributed_model
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些包含下图的,暂时不用管,等孙师傅来看~~ @sunzhongkai588
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

现在这些都变回原来的样子叭

@@ -146,6 +146,7 @@ set_lr_scheduler(scheduler)
**代码示例**

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成 copy-from 的形式叭~

@@ -139,6 +139,7 @@ set_lr_scheduler(scheduler)
**代码示例**

.. code-block:: python

Copy link
Collaborator

Choose a reason for hiding this comment

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

改成 copy-from 的形式叭~

@@ -143,6 +143,7 @@ set_lr_scheduler(scheduler)
**代码示例**

.. code-block:: python

Copy link
Collaborator

Choose a reason for hiding this comment

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

改成 copy-from 的形式叭~

@@ -162,6 +162,7 @@ set_lr_scheduler(scheduler)
**代码示例**

.. code-block:: python

Copy link
Collaborator

Choose a reason for hiding this comment

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

改成 copy-from 的形式叭~

Turingg and others added 7 commits November 14, 2023 22:31
修正COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
删去.. code-block:: python下面的代码顺带一起删了
改成 copy-from 的形式
改成 copy-from 的形式
改成 copy-from 的形式
改成 copy-from 的形式
…learning rate; 中文文档对应添加其中 start_lr 是初始学习率,而 end_lr 是最终学习率;
Copy link
Collaborator

@ooooo-create ooooo-create left a comment

Choose a reason for hiding this comment

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

修改一下~~


import paddle.distributed.fleet as fleet
fleet.init(is_collective=True)
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example2

import paddle.distributed.fleet as fleet
role = fleet.PaddleCloudRoleMaker()
fleet.init(role)
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example3

import paddle.distributed.fleet as fleet
strategy = fleet.DistributedStrategy()
fleet.init(strategy=strategy)
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example4

lr = adam.get_lr()
print("current lr is {}".format(lr))
# current lr is 0.1
COPY-FROM: paddle.optimizer.set_lr_scheduler
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY-FROM: paddle.optimizer.set_lr_scheduler
COPY-FROM: paddle.optimizer.AdamW.set_lr_scheduler

lr = adam.get_lr()
print("current lr is {}".format(lr))
# current lr is 0.1
COPY-FROM: paddle.optimizer.set_lr_scheduler
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
COPY-FROM: paddle.optimizer.set_lr_scheduler
COPY-FROM: paddle.optimizer.Adam.set_lr_scheduler

if paddle.is_compiled_with_cuda() and len(paddle.static.cuda_places()) > 0:
run_example_code()

COPY-FROM: paddle.distributed.fleet.Fleet.qat_init
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个改回原来的吧~,麻烦了~~

@@ -485,8 +485,7 @@ distributed_model(model)

**代码示例**

.. code-block:: python

COPY-FROM: paddle.distributed.fleet.Fleet.distributed_model
Copy link
Collaborator

Choose a reason for hiding this comment

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

现在这些都变回原来的样子叭

@@ -13,6 +13,7 @@ LinearWarmup

lr = start\_lr + (end\_lr - start\_lr) * \frac{epoch}{warmup\_steps}

其中 start_lr 是初始学习率,而 end_lr 是最终学习率;
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个先不修改,另外提一个叭~~

Copy link
Collaborator

@sunzhongkai588 sunzhongkai588 Nov 23, 2023

Choose a reason for hiding this comment

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

针对Fleet 下的 init 方法,copy from 后面的 name id 变了,详情请看 PaddlePaddle/Paddle#58626 (comment)

所以,针对 init 方法的代码示例,应该进行如下修改(中间加个init) @Turingg ,如

COPY-FROM: paddle.distributed.fleet.Fleet.init:code-example1
改为
COPY-FROM: paddle.distributed.fleet.Fleet.init:code-init-example1

另外,据以往的经验, Fleet 比较特殊, 该类下的方法(不只是init)很多代码示例都有可能 copy-from 不成功(即使已经符合写作要求)。如果按要求改动之后,在预览里还是无法显示正常代码,那么就不用 copy-from 的形式,直接贴上源码即可。如

code-block:: python
   import paddle.distributed.fleet as fleet
   fleet.init()

Fleet 下的 init 方法:中间加个init
qat_init:改回了原来的
包含fleetrun变回了原来的
COPY-FROM: paddle.optimizer.set_lr_scheduler
修改:COPY-FROM: paddle.optimizer.AdamW.set_lr_scheduler
COPY-FROM: paddle.optimizer.set_lr_scheduler
修改:paddle.optimizer.Adam.set_lr_scheduler
@Turingg Turingg closed this by deleting the head repository Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants