-
Notifications
You must be signed in to change notification settings - Fork 760
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
Conversation
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.
需要在英文里 doc/fluid/api/optimizer.rst 加一下对应英文的内容
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.
LinearLrWarmup的中文文档缺乏
|
||
.. math:: | ||
|
||
decayed\_learning\_rate = learning\_rate * d_{model}^{-0.5} * min(global\_steps^{-0.5}, global\_steps * warmup\_steps^{-1.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.
global_steps统一换成epoch吧,后面那几种只有epoch的概念了
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.
fixed it
.. code-block:: text | ||
|
||
例如,设定的boundaries列表为[100, 200],候选学习率常量列表values为[1.0, 0.5, 0.1],则: | ||
1、在当前训练步数global_step小于100步,学习率值为1.0。 |
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.
当前训练的epoch数
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.
fixed it
|
||
.. math:: | ||
|
||
decay\_steps &= decay\_steps * math.ceil(\frac{global\_step}{decay\_steps}) \\ |
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.
fixed it
|
||
.. math:: | ||
|
||
global\_step &= min(global\_step, decay\_steps) \\ |
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.
fixed it
已加上 |
- **learning_rate** (float) - 初始学习率,数据类型为Python float。 | ||
- **gamma** (float):衰减率。 | ||
- **last_epoch** (int,可选): 上一轮的轮数,重启训练时设置为上一轮的epoch数。默认值为 -1,则为初始学习率。 | ||
- **verbose** (bool,可选):如果是 `True` ,则在每一轮更新时在标准输出 `stdout` 输出一条信息。 |
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.
缺少Default 下同
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.
已增加
|
||
参数 | ||
::::::::: | ||
- **boundaries** (lis):指定衰减的步数边界。列表的数据元素为Python int类型。 |
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.
lis -> list
------------------------------- | ||
|
||
|
||
.. py:class:: paddle.optimizer.lr_scheduler.NaturalExpLR(learning_rate, gama, last_epoch=-1, verbose=False) |
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.
gama -> gamma default 值英文里是0.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.
必选参数
参数 | ||
::::::::: | ||
- **learning_rate** (float) - 初始学习率,数据类型为Python float。 | ||
- **gamma** (float):衰减率。 |
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.
是否为optional
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.
必选参数
------------------------------- | ||
|
||
|
||
.. py:class:: paddle.optimizer.lr_scheduler.InverseTimeLR(learning_rate, gama, last_epoch=-1, verbose=False) |
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.
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) |
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.
应该是LambdaLR
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.
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。 |
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.
factor
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.
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。 |
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.
小于epsilon
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.
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) |
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.
StepLR吧
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.
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) |
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.
fixed it
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
* Add autoShape() speed profiling * Update common.py * Create README.md * Update hubconf.py * cleanuip
Add dynamic/static learning rate doc for the api2.0.
Related with PR PaddlePaddle/Paddle#26550