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
f7f2dd01
"git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "97baba1b2cf376198fbd383bdceec53dbc932c01"
Commit
f7f2dd01
authored
Aug 01, 2018
by
Maggie Li
Committed by
Myle Ott
Aug 01, 2018
Browse files
Add ensemble for different architectures (#235)
parent
202e0bbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
fairseq/utils.py
fairseq/utils.py
+7
-4
No files found.
fairseq/utils.py
View file @
f7f2dd01
...
@@ -146,17 +146,20 @@ def load_ensemble_for_inference(filenames, task, model_arg_overrides=None):
...
@@ -146,17 +146,20 @@ def load_ensemble_for_inference(filenames, task, model_arg_overrides=None):
state
=
torch
.
load
(
filename
,
map_location
=
lambda
s
,
l
:
default_restore_location
(
s
,
'cpu'
))
state
=
torch
.
load
(
filename
,
map_location
=
lambda
s
,
l
:
default_restore_location
(
s
,
'cpu'
))
state
=
_upgrade_state_dict
(
state
)
state
=
_upgrade_state_dict
(
state
)
states
.
append
(
state
)
states
.
append
(
state
)
args
=
states
[
0
][
'args'
]
if
model_arg_overrides
is
not
None
:
args
=
_override_model_args
(
args
,
model_arg_overrides
)
# build ensemble
ensemble
=
[]
ensemble
=
[]
for
state
in
states
:
for
state
in
states
:
args
=
state
[
'args'
]
if
model_arg_overrides
is
not
None
:
args
=
_override_model_args
(
args
,
model_arg_overrides
)
# build model for ensemble
model
=
task
.
build_model
(
args
)
model
=
task
.
build_model
(
args
)
model
.
upgrade_state_dict
(
state
[
'model'
])
model
.
upgrade_state_dict
(
state
[
'model'
])
model
.
load_state_dict
(
state
[
'model'
],
strict
=
True
)
model
.
load_state_dict
(
state
[
'model'
],
strict
=
True
)
ensemble
.
append
(
model
)
ensemble
.
append
(
model
)
return
ensemble
,
args
return
ensemble
,
args
...
...
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