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
be274623
Commit
be274623
authored
Nov 15, 2017
by
Myle Ott
Browse files
Improve error when resuming training with a different model architecture
parent
d74f200a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
fairseq/utils.py
fairseq/utils.py
+5
-1
No files found.
fairseq/utils.py
View file @
be274623
...
@@ -96,7 +96,11 @@ def load_state(filename, model, criterion, optimizer, lr_scheduler, cuda_device=
...
@@ -96,7 +96,11 @@ def load_state(filename, model, criterion, optimizer, lr_scheduler, cuda_device=
state
=
_upgrade_state_dict
(
state
)
state
=
_upgrade_state_dict
(
state
)
# load model parameters
# load model parameters
model
.
load_state_dict
(
state
[
'model'
])
try
:
model
.
load_state_dict
(
state
[
'model'
])
except
:
raise
Exception
(
'Cannot load model parameters from checkpoint, '
'please ensure that the architectures match'
)
# only load optimizer and lr_scheduler if they match with the checkpoint
# only load optimizer and lr_scheduler if they match with the checkpoint
optim_history
=
state
[
'optimizer_history'
]
optim_history
=
state
[
'optimizer_history'
]
...
...
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