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
851ef592
Commit
851ef592
authored
Oct 10, 2019
by
Rémi Louf
Browse files
add comment on recursive weights loading
parent
770b15b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
transformers/modeling_utils.py
transformers/modeling_utils.py
+2
-0
No files found.
transformers/modeling_utils.py
View file @
851ef592
...
...
@@ -383,6 +383,8 @@ class PreTrainedModel(nn.Module):
if
metadata
is
not
None
:
state_dict
.
_metadata
=
metadata
# PyTorch's `_load_from_state_dict` does not copy parameters in a module's descendants
# so we need to apply the function recursively.
def
load
(
module
,
prefix
=
''
):
local_metadata
=
{}
if
metadata
is
None
else
metadata
.
get
(
prefix
[:
-
1
],
{})
module
.
_load_from_state_dict
(
...
...
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