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
55bda525
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "64e0adda81cc8fca8de9b9a3639d02925b8fdffe"
Commit
55bda525
authored
May 15, 2020
by
Julien Chaumond
Browse files
Same fix for `addcmul_`
parent
ad02c961
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/optimization.py
src/transformers/optimization.py
+3
-3
No files found.
src/transformers/optimization.py
View file @
55bda525
...
@@ -152,8 +152,8 @@ class AdamW(Optimizer):
...
@@ -152,8 +152,8 @@ class AdamW(Optimizer):
# Decay the first and second moment running average coefficient
# Decay the first and second moment running average coefficient
# In-place operations to update the averages at the same time
# In-place operations to update the averages at the same time
exp_avg
.
mul_
(
beta1
).
add_
(
grad
,
alpha
=
1.0
-
beta1
)
exp_avg
.
mul_
(
beta1
).
add_
(
grad
,
1.0
-
beta1
)
exp_avg_sq
.
mul_
(
beta2
).
addcmul_
(
1.0
-
beta2
,
grad
,
grad
)
exp_avg_sq
.
mul_
(
beta2
).
addcmul_
(
grad
,
grad
,
1.0
-
beta2
)
denom
=
exp_avg_sq
.
sqrt
().
add_
(
group
[
"eps"
])
denom
=
exp_avg_sq
.
sqrt
().
add_
(
group
[
"eps"
])
step_size
=
group
[
"lr"
]
step_size
=
group
[
"lr"
]
...
@@ -173,6 +173,6 @@ class AdamW(Optimizer):
...
@@ -173,6 +173,6 @@ class AdamW(Optimizer):
# of the weights to the loss with plain (non-momentum) SGD.
# of the weights to the loss with plain (non-momentum) SGD.
# Add weight decay at the end (fixed version)
# Add weight decay at the end (fixed version)
if
group
[
"weight_decay"
]
>
0.0
:
if
group
[
"weight_decay"
]
>
0.0
:
p
.
data
.
add_
(
p
.
data
,
alpha
=
-
group
[
"lr"
]
*
group
[
"weight_decay"
])
p
.
data
.
add_
(
p
.
data
,
-
group
[
"lr"
]
*
group
[
"weight_decay"
])
return
loss
return
loss
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