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
79bbe1d8
"docker/release" did not exist on "6f3c5f1c23c25fa439a9f656afef0a0b3495ffac"
Commit
79bbe1d8
authored
Jul 26, 2018
by
theweiho
Committed by
Myle Ott
Jul 26, 2018
Browse files
Add load_optim option to load checkpoint but not optimizer state (#229)
parent
5d99e139
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
fairseq/trainer.py
fairseq/trainer.py
+11
-9
No files found.
fairseq/trainer.py
View file @
79bbe1d8
...
...
@@ -80,15 +80,17 @@ class Trainer(object):
self
.
lr_scheduler
,
self
.
_num_updates
,
self
.
_optim_history
,
extra_state
,
)
def
load_checkpoint
(
self
,
filename
):
def
load_checkpoint
(
self
,
filename
,
load_optim
=
True
):
"""Load all training state from a checkpoint file."""
extra_state
,
self
.
_
optim_history
,
last_optim_state
=
\
extra_state
,
optim_history
,
last_optim_state
=
\
utils
.
load_model_state
(
filename
,
self
.
model
)
if
last_optim_state
is
not
None
:
# rebuild optimizer after loading model, since params may have changed
self
.
_build_optimizer
()
if
load_optim
:
self
.
_optim_history
=
optim_history
# only reload optimizer and lr_scheduler if they match
last_optim
=
self
.
_optim_history
[
-
1
]
if
last_optim
[
'criterion_name'
]
==
self
.
criterion
.
__class__
.
__name__
:
...
...
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