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
33aafc26
Unverified
Commit
33aafc26
authored
Jul 11, 2023
by
Sylvain Gugger
Committed by
GitHub
Jul 11, 2023
Browse files
Skip keys not in the state dict when finding mismatched weights (#24749)
parent
3d869726
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+3
-0
No files found.
src/transformers/modeling_utils.py
View file @
33aafc26
...
...
@@ -3157,6 +3157,9 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
mismatched_keys
=
[]
if
ignore_mismatched_sizes
:
for
checkpoint_key
in
loaded_keys
:
# If the checkpoint is sharded, we may not have the key here.
if
checkpoint_key
not
in
state_dict
:
continue
model_key
=
checkpoint_key
if
remove_prefix_from_model
:
# The model key starts with `prefix` but `checkpoint_key` doesn't so we add it.
...
...
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