Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
de890ae6
Commit
de890ae6
authored
Nov 05, 2019
by
Dom Hudson
Committed by
Lysandre Debut
Nov 05, 2019
Browse files
Updating docblocks in optimizers.py
parent
d7d36181
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
transformers/optimization.py
transformers/optimization.py
+13
-9
No files found.
transformers/optimization.py
View file @
de890ae6
...
@@ -32,8 +32,9 @@ class ConstantLRSchedule(LambdaLR):
...
@@ -32,8 +32,9 @@ class ConstantLRSchedule(LambdaLR):
class
WarmupConstantSchedule
(
LambdaLR
):
class
WarmupConstantSchedule
(
LambdaLR
):
""" Linear warmup and then constant.
""" Linear warmup and then constant.
Linearly increases learning rate schedule from 0 to 1 over `warmup_steps` training steps.
Multiplies the learning rate defined in the optimizer by a dynamic variable determined by the current step.
Keeps learning rate schedule equal to 1. after warmup_steps.
Linearly increases the multiplicative variable from 0. to 1. over `warmup_steps` training steps.
Keeps multiplicative variable equal to 1. after warmup_steps.
"""
"""
def
__init__
(
self
,
optimizer
,
warmup_steps
,
last_epoch
=-
1
):
def
__init__
(
self
,
optimizer
,
warmup_steps
,
last_epoch
=-
1
):
self
.
warmup_steps
=
warmup_steps
self
.
warmup_steps
=
warmup_steps
...
@@ -47,8 +48,9 @@ class WarmupConstantSchedule(LambdaLR):
...
@@ -47,8 +48,9 @@ class WarmupConstantSchedule(LambdaLR):
class
WarmupLinearSchedule
(
LambdaLR
):
class
WarmupLinearSchedule
(
LambdaLR
):
""" Linear warmup and then linear decay.
""" Linear warmup and then linear decay.
Linearly increases learning rate from 0 to 1 over `warmup_steps` training steps.
Multiplies the learning rate defined in the optimizer by a dynamic variable determined by the current step.
Linearly decreases learning rate from 1. to 0. over remaining `t_total - warmup_steps` steps.
Linearly increases the multiplicative variable from 0. to 1. over `warmup_steps` training steps.
Linearly decreases the multiplicative variable from 1. to 0. over remaining `t_total - warmup_steps` steps.
"""
"""
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
last_epoch
=-
1
):
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
last_epoch
=-
1
):
self
.
warmup_steps
=
warmup_steps
self
.
warmup_steps
=
warmup_steps
...
@@ -63,9 +65,10 @@ class WarmupLinearSchedule(LambdaLR):
...
@@ -63,9 +65,10 @@ class WarmupLinearSchedule(LambdaLR):
class
WarmupCosineSchedule
(
LambdaLR
):
class
WarmupCosineSchedule
(
LambdaLR
):
""" Linear warmup and then cosine decay.
""" Linear warmup and then cosine decay.
Linearly increases learning rate from 0 to 1 over `warmup_steps` training steps.
Multiplies the learning rate defined in the optimizer by a dynamic variable determined by the current step.
Decreases learning rate from 1. to 0. over remaining `t_total - warmup_steps` steps following a cosine curve.
Linearly increases the multiplicative variable from 0. to 1. over `warmup_steps` training steps.
If `cycles` (default=0.5) is different from default, learning rate follows cosine function after warmup.
Decreases the multiplicative variable from 1. to 0. over remaining `t_total - warmup_steps` steps following a cosine curve.
If `cycles` (default=0.5) is different from default, then the multiplicative variable follows cosine function after warmup.
"""
"""
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
cycles
=
.
5
,
last_epoch
=-
1
):
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
cycles
=
.
5
,
last_epoch
=-
1
):
self
.
warmup_steps
=
warmup_steps
self
.
warmup_steps
=
warmup_steps
...
@@ -83,8 +86,9 @@ class WarmupCosineSchedule(LambdaLR):
...
@@ -83,8 +86,9 @@ class WarmupCosineSchedule(LambdaLR):
class
WarmupCosineWithHardRestartsSchedule
(
LambdaLR
):
class
WarmupCosineWithHardRestartsSchedule
(
LambdaLR
):
""" Linear warmup and then cosine cycles with hard restarts.
""" Linear warmup and then cosine cycles with hard restarts.
Linearly increases learning rate from 0 to 1 over `warmup_steps` training steps.
Multiplies the learning rate defined in the optimizer by a dynamic variable determined by the current step.
If `cycles` (default=1.) is different from default, learning rate follows `cycles` times a cosine decaying
Linearly increases the multiplicative variable from 0. to 1. over `warmup_steps` training steps.
If `cycles` (default=1.) is different from default, learning rate follows `cycles` times a cosine decaying
learning rate (with hard restarts).
learning rate (with hard restarts).
"""
"""
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
cycles
=
1.
,
last_epoch
=-
1
):
def
__init__
(
self
,
optimizer
,
warmup_steps
,
t_total
,
cycles
=
1.
,
last_epoch
=-
1
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment