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
69f2d538
Unverified
Commit
69f2d538
authored
Apr 24, 2023
by
hanrui1sensetime
Committed by
GitHub
Apr 24, 2023
Browse files
[Fix Bugs] Fix keys in `_load_pretrained_model` (#22947)
fix transformers keys
parent
b5f06d6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+2
-2
No files found.
src/transformers/modeling_utils.py
View file @
69f2d538
...
@@ -2956,8 +2956,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -2956,8 +2956,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
for
key
in
missing_keys
:
for
key
in
missing_keys
:
if
key
in
list
(
model_state_dict
.
keys
()):
if
key
in
list
(
model_state_dict
.
keys
()):
key
=
key
key
=
key
elif
f
"
{
prefix
}
.key"
in
list
(
model_state_dict
.
keys
()):
elif
f
"
{
prefix
}
.
{
key
}
"
in
list
(
model_state_dict
.
keys
()):
key
=
f
"
{
prefix
}
.key"
key
=
f
"
{
prefix
}
.
{
key
}
"
elif
key
.
startswith
(
prefix
)
and
"."
.
join
(
key
.
split
(
"."
)[
1
:])
in
list
(
model_state_dict
.
keys
()):
elif
key
.
startswith
(
prefix
)
and
"."
.
join
(
key
.
split
(
"."
)[
1
:])
in
list
(
model_state_dict
.
keys
()):
key
=
"."
.
join
(
key
.
split
(
"."
)[
1
:])
key
=
"."
.
join
(
key
.
split
(
"."
)[
1
:])
param
=
model_state_dict
[
key
]
param
=
model_state_dict
[
key
]
...
...
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