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
2d91e3c3
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "a39dfe4fb122c11be98a563fb8ca43b322e01036"
Unverified
Commit
2d91e3c3
authored
Apr 27, 2022
by
Yongliang Shen
Committed by
GitHub
Apr 26, 2022
Browse files
use original loaded keys to find mismatched keys (#16920)
parent
d365f507
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+3
-2
No files found.
src/transformers/modeling_utils.py
View file @
2d91e3c3
...
@@ -2022,6 +2022,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -2022,6 +2022,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
return
key
.
replace
(
"gamma"
,
"weight"
)
return
key
.
replace
(
"gamma"
,
"weight"
)
return
key
return
key
original_loaded_keys
=
loaded_keys
loaded_keys
=
[
_fix_key
(
key
)
for
key
in
loaded_keys
]
loaded_keys
=
[
_fix_key
(
key
)
for
key
in
loaded_keys
]
if
len
(
prefix
)
>
0
:
if
len
(
prefix
)
>
0
:
...
@@ -2114,7 +2115,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -2114,7 +2115,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
mismatched_keys
=
_find_mismatched_keys
(
mismatched_keys
=
_find_mismatched_keys
(
state_dict
,
state_dict
,
model_state_dict
,
model_state_dict
,
loaded_keys
,
original_
loaded_keys
,
add_prefix_to_model
,
add_prefix_to_model
,
remove_prefix_from_model
,
remove_prefix_from_model
,
ignore_mismatched_sizes
,
ignore_mismatched_sizes
,
...
@@ -2140,7 +2141,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -2140,7 +2141,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
mismatched_keys
+=
_find_mismatched_keys
(
mismatched_keys
+=
_find_mismatched_keys
(
state_dict
,
state_dict
,
model_state_dict
,
model_state_dict
,
loaded_keys
,
original_
loaded_keys
,
add_prefix_to_model
,
add_prefix_to_model
,
remove_prefix_from_model
,
remove_prefix_from_model
,
ignore_mismatched_sizes
,
ignore_mismatched_sizes
,
...
...
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