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
baf66d14
"...resnet50_tensorflow.git" did not exist on "73d48524d94ea8b78a13735c6b476c60f0babcba"
Commit
baf66d14
authored
Mar 12, 2019
by
lukovnikov
Browse files
restart cosine lr schedule
parent
51efde54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
pytorch_pretrained_bert/optimization.py
pytorch_pretrained_bert/optimization.py
+17
-1
No files found.
pytorch_pretrained_bert/optimization.py
View file @
baf66d14
...
...
@@ -69,7 +69,23 @@ class WarmupCosineSchedule(LRSchedule):
return
progress
/
self
.
warmup
else
:
progress
=
(
progress
-
self
.
warmup
)
/
(
1
-
self
.
warmup
)
# progress after warmup
return
0.5
*
(
1.
+
math
.
cos
(
math
.
pi
*
self
.
cycles
*
2
*
progress
))
return
0.5
*
(
1.
+
math
.
cos
(
math
.
pi
*
((
self
.
cycles
*
2
*
progress
)
%
1
))
class
WarmupCosineWithRestartsSchedule
(
WarmupCosineSchedule
):
warn_t_total
=
True
def
__init__
(
self
,
warmup
=
0.002
,
t_total
=-
1
,
cycles
=
1.
,
**
kw
):
super
(
WarmupCosineWithRestartsSchedule
,
self
).
__init__
(
warmup
=
warmup
,
t_total
=
t_total
,
cycles
=
cycles
,
**
kw
)
def
get_lr_
(
self
,
progress
):
if
self
.
t_total
<=
0
:
return
1.
if
progress
<
self
.
warmup
:
return
progress
/
self
.
warmup
else
:
progress
=
(
progress
-
self
.
warmup
)
/
(
1
-
self
.
warmup
)
# progress after warmup
ret
=
0.5
*
(
1.
+
math
.
cos
(
math
.
pi
*
self
.
cycles
*
2
*
progress
))
return
ret
class
WarmupConstantSchedule
(
LRSchedule
):
...
...
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