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
bec02ff2
Unverified
Commit
bec02ff2
authored
Nov 10, 2021
by
Chang Wang
Committed by
GitHub
Nov 10, 2021
Browse files
enhance rewrite state_dict missing _metadata (#14348)
parent
2b0d9389
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+2
-1
No files found.
src/transformers/modeling_utils.py
View file @
bec02ff2
...
@@ -1050,6 +1050,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -1050,6 +1050,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
# Handle the case where some state_dict keys shouldn't be saved
# Handle the case where some state_dict keys shouldn't be saved
if
self
.
_keys_to_ignore_on_save
is
not
None
:
if
self
.
_keys_to_ignore_on_save
is
not
None
:
for
ignore_key
in
self
.
_keys_to_ignore_on_save
:
for
ignore_key
in
self
.
_keys_to_ignore_on_save
:
if
ignore_key
in
state_dict
.
keys
():
del
state_dict
[
ignore_key
]
del
state_dict
[
ignore_key
]
# If we save using the predefined names, we can load using `from_pretrained`
# If we save using the predefined names, we can load using `from_pretrained`
...
...
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