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
OpenDAS
Megatron-LM
Commits
7a3b4c15
Commit
7a3b4c15
authored
Jan 13, 2020
by
Mohammad Shoeybi
Browse files
exponential learning rate decay added
parent
2d76d065
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
megatron/learning_rates.py
megatron/learning_rates.py
+4
-1
No files found.
megatron/learning_rates.py
View file @
7a3b4c15
...
...
@@ -24,7 +24,7 @@ from megatron.utils import print_rank_0
class
AnnealingLR
(
_LRScheduler
):
"""Anneals the learning rate"""
DECAY_STYLES
=
[
'linear'
,
'cosine'
,
'constant'
,
'None'
]
DECAY_STYLES
=
[
'linear'
,
'cosine'
,
'exponential'
,
'constant'
,
'None'
]
def
__init__
(
self
,
optimizer
,
start_lr
,
warmup_iter
,
num_iters
,
decay_style
=
None
,
last_iter
=-
1
,
min_lr
=
0.0
,
...
...
@@ -57,6 +57,9 @@ class AnnealingLR(_LRScheduler):
lr
=
self
.
start_lr
*
((
self
.
end_iter
-
(
num_iters_
-
self
.
warmup_iter
))
/
self
.
end_iter
)
elif
self
.
decay_style
==
self
.
DECAY_STYLES
[
1
]:
lr
=
self
.
start_lr
/
2.0
*
(
math
.
cos
(
math
.
pi
*
(
num_iters_
-
self
.
warmup_iter
)
/
self
.
end_iter
)
+
1
)
elif
self
.
decay_style
==
self
.
DECAY_STYLES
[
2
]:
# exp(-0.693) = 1/2
lr
=
self
.
start_lr
*
math
.
exp
(
-
0.693
*
(
num_iters_
-
self
.
warmup_iter
)
/
self
.
end_iter
)
else
:
lr
=
self
.
start_lr
return
max
(
lr
,
self
.
min_lr
)
...
...
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