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
94adad6b
Unverified
Commit
94adad6b
authored
Apr 02, 2019
by
Thomas Wolf
Committed by
GitHub
Apr 02, 2019
Browse files
Merge pull request #435 from marpaia/training-fixes
Fixes to the TensorFlow conversion tool
parents
ec5c1d61
8b5c63e4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
examples/extract_features.py
examples/extract_features.py
+1
-1
pytorch_pretrained_bert/modeling.py
pytorch_pretrained_bert/modeling.py
+6
-2
No files found.
examples/extract_features.py
View file @
94adad6b
...
@@ -57,7 +57,7 @@ class InputFeatures(object):
...
@@ -57,7 +57,7 @@ class InputFeatures(object):
def
convert_examples_to_features
(
examples
,
seq_length
,
tokenizer
):
def
convert_examples_to_features
(
examples
,
seq_length
,
tokenizer
):
"""Loads a data file into a list of `Input
Batch
`s."""
"""Loads a data file into a list of `Input
Feature
`s."""
features
=
[]
features
=
[]
for
(
ex_index
,
example
)
in
enumerate
(
examples
):
for
(
ex_index
,
example
)
in
enumerate
(
examples
):
...
...
pytorch_pretrained_bert/modeling.py
View file @
94adad6b
...
@@ -76,7 +76,7 @@ def load_tf_weights_in_bert(model, tf_checkpoint_path):
...
@@ -76,7 +76,7 @@ def load_tf_weights_in_bert(model, tf_checkpoint_path):
name
=
name
.
split
(
'/'
)
name
=
name
.
split
(
'/'
)
# adam_v and adam_m are variables used in AdamWeightDecayOptimizer to calculated m and v
# adam_v and adam_m are variables used in AdamWeightDecayOptimizer to calculated m and v
# which are not required for using pretrained model
# which are not required for using pretrained model
if
any
(
n
in
[
"adam_v"
,
"adam_m"
]
for
n
in
name
):
if
any
(
n
in
[
"adam_v"
,
"adam_m"
,
"global_step"
]
for
n
in
name
):
print
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
print
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
continue
pointer
=
model
pointer
=
model
...
@@ -92,7 +92,11 @@ def load_tf_weights_in_bert(model, tf_checkpoint_path):
...
@@ -92,7 +92,11 @@ def load_tf_weights_in_bert(model, tf_checkpoint_path):
elif
l
[
0
]
==
'output_weights'
:
elif
l
[
0
]
==
'output_weights'
:
pointer
=
getattr
(
pointer
,
'weight'
)
pointer
=
getattr
(
pointer
,
'weight'
)
else
:
else
:
try
:
pointer
=
getattr
(
pointer
,
l
[
0
])
pointer
=
getattr
(
pointer
,
l
[
0
])
except
AttributeError
:
print
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
if
len
(
l
)
>=
2
:
if
len
(
l
)
>=
2
:
num
=
int
(
l
[
1
])
num
=
int
(
l
[
1
])
pointer
=
pointer
[
num
]
pointer
=
pointer
[
num
]
...
...
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