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
e7cfc46f
Commit
e7cfc46f
authored
Feb 13, 2019
by
thomwolf
Browse files
fix TransfoXLModel loading
parent
3c33499f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
pytorch_pretrained_bert/modeling_transfo_xl.py
pytorch_pretrained_bert/modeling_transfo_xl.py
+6
-1
No files found.
pytorch_pretrained_bert/modeling_transfo_xl.py
View file @
e7cfc46f
...
@@ -959,7 +959,12 @@ class TransfoXLPreTrainedModel(nn.Module):
...
@@ -959,7 +959,12 @@ class TransfoXLPreTrainedModel(nn.Module):
for
name
,
child
in
module
.
_modules
.
items
():
for
name
,
child
in
module
.
_modules
.
items
():
if
child
is
not
None
:
if
child
is
not
None
:
load
(
child
,
prefix
+
name
+
'.'
)
load
(
child
,
prefix
+
name
+
'.'
)
load
(
model
,
prefix
=
''
)
start_prefix
=
''
if
not
hasattr
(
model
,
'transformer'
)
and
any
(
s
.
startswith
(
'transformer.'
)
for
s
in
state_dict
.
keys
()):
start_prefix
=
'transformer.'
load
(
model
,
prefix
=
start_prefix
)
if
len
(
missing_keys
)
>
0
:
if
len
(
missing_keys
)
>
0
:
logger
.
info
(
"Weights of {} not initialized from pretrained model: {}"
.
format
(
logger
.
info
(
"Weights of {} not initialized from pretrained model: {}"
.
format
(
model
.
__class__
.
__name__
,
missing_keys
))
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