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
Fairseq
Commits
9a951216
Commit
9a951216
authored
Feb 08, 2018
by
Sergey Edunov
Browse files
Adjust weight decay by the current learning rate to make it work correctly during annealing
parent
e4c935aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
fairseq/optim/adam.py
fairseq/optim/adam.py
+1
-1
fairseq/optim/nag.py
fairseq/optim/nag.py
+1
-1
No files found.
fairseq/optim/adam.py
View file @
9a951216
...
...
@@ -96,7 +96,7 @@ class Adam(Optimizer):
step_size
=
group
[
'lr'
]
*
math
.
sqrt
(
bias_correction2
)
/
bias_correction1
if
group
[
'weight_decay'
]
!=
0
:
p
.
data
.
add_
(
-
group
[
'weight_decay'
],
p
.
data
)
p
.
data
.
add_
(
-
group
[
'weight_decay'
]
*
group
[
'lr'
]
,
p
.
data
)
p
.
data
.
addcdiv_
(
-
step_size
,
exp_avg
,
denom
)
...
...
fairseq/optim/nag.py
View file @
9a951216
...
...
@@ -44,7 +44,7 @@ class NAG(Optimizer):
buf
=
param_state
[
'momentum_buffer'
]
if
weight_decay
!=
0
:
p
.
data
.
mul_
(
1
-
weight_decay
)
p
.
data
.
mul_
(
1
-
lr
*
weight_decay
)
p
.
data
.
add_
(
momentum
*
momentum
*
lr_correct
,
buf
)
p
.
data
.
add_
(
-
(
1
+
momentum
)
*
lr
,
d_p
)
...
...
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