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

Add dynamic/static learning rate doc for the api2.0 #2459

Merged
merged 15 commits into from
Aug 28, 2020

Conversation

wawltor
Copy link
Contributor

@wawltor wawltor commented Aug 22, 2020

Add dynamic/static learning rate doc for the api2.0.

Related with PR PaddlePaddle/Paddle#26550

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

image
image
image

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

image
image
image

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

image
image
image
image
image
image
image

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

image
image
image
image
image
image
image
image
image
image

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

image
image
image
image
image
image

Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

需要在英文里 doc/fluid/api/optimizer.rst 加一下对应英文的内容

@zhwesky2010 zhwesky2010 changed the title Add dynamic learning rate doc for the api2.0 Add dynamic/static learning rate doc for the api2.0 Aug 23, 2020
Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LinearLrWarmup的中文文档缺乏


.. math::

decayed\_learning\_rate = learning\_rate * d_{model}^{-0.5} * min(global\_steps^{-0.5}, global\_steps * warmup\_steps^{-1.5})
Copy link
Collaborator

Choose a reason for hiding this comment

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

global_steps统一换成epoch吧,后面那几种只有epoch的概念了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

.. code-block:: text

例如,设定的boundaries列表为[100, 200],候选学习率常量列表values为[1.0, 0.5, 0.1],则:
1、在当前训练步数global_step小于100步,学习率值为1.0。
Copy link
Collaborator

Choose a reason for hiding this comment

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

当前训练的epoch数

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it


.. math::

decay\_steps &= decay\_steps * math.ceil(\frac{global\_step}{decay\_steps}) \\
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
Contributor Author

Choose a reason for hiding this comment

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

fixed it


.. math::

global\_step &= min(global\_step, decay\_steps) \\
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
Contributor Author

Choose a reason for hiding this comment

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

fixed it

@wawltor
Copy link
Contributor Author

wawltor commented Aug 23, 2020

LinearLrWarmup的中文文档缺乏

已加上

- **learning_rate** (float) - 初始学习率,数据类型为Python float。
- **gamma** (float):衰减率。
- **last_epoch** (int,可选): 上一轮的轮数,重启训练时设置为上一轮的epoch数。默认值为 -1,则为初始学习率。
- **verbose** (bool,可选):如果是 `True` ,则在每一轮更新时在标准输出 `stdout` 输出一条信息。
Copy link
Collaborator

Choose a reason for hiding this comment

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

缺少Default 下同

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已增加


参数
:::::::::
- **boundaries** (lis):指定衰减的步数边界。列表的数据元素为Python int类型。
Copy link
Collaborator

Choose a reason for hiding this comment

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

lis -> list

-------------------------------


.. py:class:: paddle.optimizer.lr_scheduler.NaturalExpLR(learning_rate, gama, last_epoch=-1, verbose=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

gama -> gamma default 值英文里是0.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

必选参数

参数
:::::::::
- **learning_rate** (float) - 初始学习率,数据类型为Python float。
- **gamma** (float):衰减率。
Copy link
Collaborator

Choose a reason for hiding this comment

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

是否为optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

必选参数

-------------------------------


.. py:class:: paddle.optimizer.lr_scheduler.InverseTimeLR(learning_rate, gama, last_epoch=-1, verbose=False)
Copy link
Collaborator

@TCChenlong TCChenlong Aug 24, 2020

Choose a reason for hiding this comment

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

gamma

paddle.disable_static()
x = np.random.uniform(-1, 1, [10, 10]).astype("float32")
linear = paddle.nn.Linear(10, 10)
scheduler = paddle.optimizer.StepLR(learning_rate=0.5, step_size=5, gamma=0.8, verbose=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

应该是LambdaLR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

:::::::::
- **learning_rate** (float) - 初始学习率,数据类型为Python float。
- **mode** (str,可选)'min' 和 'max' 之一。通常情况下,为 'min' ,此时当 loss 停止下降时学习率将减小。默认:'min' 。 (注意:仅在特殊用法时,可以将其设置为 'max' ,此时判断逻辑相反, loss 停止上升学习率才减小)
- **fator** (float,可选) - 学习率衰减的比例。new_lr = origin_lr * factor,它是值小于1.0的float型数字,默认: 0.1。
Copy link
Collaborator

Choose a reason for hiding this comment

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

factor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

- **threshold_mode** (str,可选)- 'rel' 和 'abs' 之一。在 'rel' 模式下, loss 最小变化的阈值是 last_loss * threshold , 其中 last_loss 是 loss 在上个epoch的值。在 'abs' 模式下,loss 最小变化的阈值是 threshold 。 默认:'rel'。
- **cooldown** (int,可选)- 在学习速率每次减小之后,会进入时长为 ``cooldown`` 个 step 的冷静期。默认:0。
- **min_lr** (float,可选) - 最小的学习率。减小后的学习率最低下界限。默认:0。
- **epsilon** (float,可选)- 如果新旧学习率间的差异小于 eps ,则不会更新。默认值:1e-8。
Copy link
Collaborator

Choose a reason for hiding this comment

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

小于epsilon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

paddle.disable_static()
x = np.random.uniform(-1, 1, [10, 10]).astype("float32")
linear = paddle.nn.Linear(10, 10)
scheduler = paddle.optimizer.MultiStepLR(learning_rate=0.5, milestones=[2, 4, 6], gamma=0.8, verbose=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

StepLR吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it

y = paddle.static.data(name='y', shape=[-1, 4, 5])
z = paddle.static.nn.fc(x, 100)
loss = paddle.mean(z)
scheduler = paddle.optimizer.MultiStepLR(learning_rate=0.5, milestones=[2, 4, 6], gamma=0.8, verbose=True)
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
Contributor Author

Choose a reason for hiding this comment

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

fixed it

Copy link
Collaborator

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

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

LGTM

@CLAassistant
Copy link

CLAassistant commented Aug 27, 2020

CLA assistant check
All committers have signed the CLA.

@wawltor wawltor merged commit bd0935e into PaddlePaddle:develop Aug 28, 2020
RichardWooSJTU pushed a commit to RichardWooSJTU/docs that referenced this pull request Apr 8, 2022
* Add autoShape() speed profiling

* Update common.py

* Create README.md

* Update hubconf.py

* cleanuip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants