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
bd3b3aee
Commit
bd3b3aee
authored
Jan 28, 2019
by
thomwolf
Browse files
update
parent
a45a9cc0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
pytorch_pretrained_bert/modeling.py
pytorch_pretrained_bert/modeling.py
+2
-1
pytorch_pretrained_bert/modeling_openai.py
pytorch_pretrained_bert/modeling_openai.py
+4
-1
No files found.
pytorch_pretrained_bert/modeling.py
View file @
bd3b3aee
...
...
@@ -606,7 +606,8 @@ class BertPreTrainedModel(nn.Module):
for
name
,
child
in
module
.
_modules
.
items
():
if
child
is
not
None
:
load
(
child
,
prefix
+
name
+
'.'
)
load
(
model
,
prefix
=
''
if
hasattr
(
model
,
'bert'
)
else
'bert.'
)
start_prefix
=
'bert.'
if
not
hasattr
(
model
,
'bert'
)
and
any
(
s
.
startwith
(
'bert.'
)
for
s
in
state_dict
.
keys
())
else
''
load
(
model
,
prefix
=
start_prefix
)
if
len
(
missing_keys
)
>
0
:
logger
.
info
(
"Weights of {} not initialized from pretrained model: {}"
.
format
(
model
.
__class__
.
__name__
,
missing_keys
))
...
...
pytorch_pretrained_bert/modeling_openai.py
View file @
bd3b3aee
...
...
@@ -502,7 +502,10 @@ class OpenAIGPTPreTrainedModel(nn.Module):
if
child
is
not
None
:
load
(
child
,
prefix
+
name
+
"."
)
load
(
model
.
transformer
if
hasattr
(
model
,
"transformer"
)
else
model
,
prefix
=
""
)
if
hasattr
(
model
,
"transformer"
)
and
all
(
not
s
.
startwith
(
'transformer.'
)
for
s
in
state_dict
.
keys
()):
start_model
=
model
.
transformer
load
(
start_model
,
prefix
=
""
)
if
len
(
missing_keys
)
>
0
:
logger
.
info
(
"Weights of {} not initialized from pretrained model: {}"
.
format
(
model
.
__class__
.
__name__
,
missing_keys
)
...
...
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