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
73368963
"examples/vscode:/vscode.git/clone" did not exist on "fbcd3ba6b27a2b019c7209aeb3073c41b72bff43"
Commit
73368963
authored
Jan 27, 2020
by
monologg
Committed by
Lysandre Debut
Feb 07, 2020
Browse files
Fix importing unofficial TF models with extra optimizer weights
parent
d7dabfef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
src/transformers/modeling_albert.py
src/transformers/modeling_albert.py
+7
-1
src/transformers/modeling_bert.py
src/transformers/modeling_bert.py
+4
-1
src/transformers/modeling_t5.py
src/transformers/modeling_t5.py
+4
-1
templates/adding_a_new_model/modeling_xxx.py
templates/adding_a_new_model/modeling_xxx.py
+4
-1
No files found.
src/transformers/modeling_albert.py
View file @
73368963
...
@@ -117,7 +117,13 @@ def load_tf_weights_in_albert(model, config, tf_checkpoint_path):
...
@@ -117,7 +117,13 @@ def load_tf_weights_in_albert(model, config, tf_checkpoint_path):
name
=
name
.
split
(
"/"
)
name
=
name
.
split
(
"/"
)
# Ignore the gradients applied by the LAMB/ADAM optimizers.
# Ignore the gradients applied by the LAMB/ADAM optimizers.
if
"adam_m"
in
name
or
"adam_v"
in
name
or
"global_step"
in
name
:
if
(
"adam_m"
in
name
or
"adam_v"
in
name
or
"AdamWeightDecayOptimizer"
in
name
or
"AdamWeightDecayOptimizer_1"
in
name
or
"global_step"
in
name
):
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
continue
...
...
src/transformers/modeling_bert.py
View file @
73368963
...
@@ -86,7 +86,10 @@ def load_tf_weights_in_bert(model, config, tf_checkpoint_path):
...
@@ -86,7 +86,10 @@ def load_tf_weights_in_bert(model, config, 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"
,
"global_step"
]
for
n
in
name
):
if
any
(
n
in
[
"adam_v"
,
"adam_m"
,
"AdamWeightDecayOptimizer"
,
"AdamWeightDecayOptimizer_1"
,
"global_step"
]
for
n
in
name
):
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
continue
pointer
=
model
pointer
=
model
...
...
src/transformers/modeling_t5.py
View file @
73368963
...
@@ -79,7 +79,10 @@ def load_tf_weights_in_t5(model, config, tf_checkpoint_path):
...
@@ -79,7 +79,10 @@ def load_tf_weights_in_t5(model, config, tf_checkpoint_path):
name
=
txt_name
.
split
(
"/"
)
name
=
txt_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"
,
"global_step"
]
for
n
in
name
):
if
any
(
n
in
[
"adam_v"
,
"adam_m"
,
"AdamWeightDecayOptimizer"
,
"AdamWeightDecayOptimizer_1"
,
"global_step"
]
for
n
in
name
):
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
tf_weights
.
pop
(
txt_name
,
None
)
tf_weights
.
pop
(
txt_name
,
None
)
continue
continue
...
...
templates/adding_a_new_model/modeling_xxx.py
View file @
73368963
...
@@ -76,7 +76,10 @@ def load_tf_weights_in_xxx(model, config, tf_checkpoint_path):
...
@@ -76,7 +76,10 @@ def load_tf_weights_in_xxx(model, config, 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"
,
"global_step"
]
for
n
in
name
):
if
any
(
n
in
[
"adam_v"
,
"adam_m"
,
"AdamWeightDecayOptimizer"
,
"AdamWeightDecayOptimizer_1"
,
"global_step"
]
for
n
in
name
):
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
continue
pointer
=
model
pointer
=
model
...
...
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