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
db4dccd1
Unverified
Commit
db4dccd1
authored
Apr 03, 2019
by
Thomas Wolf
Committed by
GitHub
Apr 03, 2019
Browse files
Merge pull request #389 from lukovnikov/master
Fix cosine schedule
parents
19666dcb
19cc2c08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
pytorch_pretrained_bert/optimization.py
pytorch_pretrained_bert/optimization.py
+2
-1
pytorch_pretrained_bert/optimization_openai.py
pytorch_pretrained_bert/optimization_openai.py
+2
-1
No files found.
pytorch_pretrained_bert/optimization.py
View file @
db4dccd1
...
@@ -26,7 +26,8 @@ logger = logging.getLogger(__name__)
...
@@ -26,7 +26,8 @@ logger = logging.getLogger(__name__)
def
warmup_cosine
(
x
,
warmup
=
0.002
):
def
warmup_cosine
(
x
,
warmup
=
0.002
):
if
x
<
warmup
:
if
x
<
warmup
:
return
x
/
warmup
return
x
/
warmup
return
0.5
*
(
1.0
+
torch
.
cos
(
math
.
pi
*
x
))
x_
=
(
x
-
warmup
)
/
(
1
-
warmup
)
# progress after warmup -
return
0.5
*
(
1.
+
math
.
cos
(
math
.
pi
*
x_
))
def
warmup_constant
(
x
,
warmup
=
0.002
):
def
warmup_constant
(
x
,
warmup
=
0.002
):
""" Linearly increases learning rate over `warmup`*`t_total` (as provided to BertAdam) training steps.
""" Linearly increases learning rate over `warmup`*`t_total` (as provided to BertAdam) training steps.
...
...
pytorch_pretrained_bert/optimization_openai.py
View file @
db4dccd1
...
@@ -26,7 +26,8 @@ logger = logging.getLogger(__name__)
...
@@ -26,7 +26,8 @@ logger = logging.getLogger(__name__)
def
warmup_cosine
(
x
,
warmup
=
0.002
):
def
warmup_cosine
(
x
,
warmup
=
0.002
):
if
x
<
warmup
:
if
x
<
warmup
:
return
x
/
warmup
return
x
/
warmup
return
0.5
*
(
1.0
+
torch
.
cos
(
math
.
pi
*
x
))
x_
=
(
x
-
warmup
)
/
(
1
-
warmup
)
# progress after warmup
return
0.5
*
(
1.
+
math
.
cos
(
math
.
pi
*
x_
))
def
warmup_constant
(
x
,
warmup
=
0.002
):
def
warmup_constant
(
x
,
warmup
=
0.002
):
""" Linearly increases learning rate over `warmup`*`t_total` (as provided to OpenAIAdam) training steps.
""" Linearly increases learning rate over `warmup`*`t_total` (as provided to OpenAIAdam) training steps.
...
...
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