Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
e85855f2
Commit
e85855f2
authored
Dec 02, 2019
by
Lysandre
Browse files
Fix ALBERT exports with pretraining + sp classifier; Fix naming for ALBERT TF models
parent
b3d834ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
transformers/modeling_albert.py
transformers/modeling_albert.py
+16
-1
transformers/modeling_tf_albert.py
transformers/modeling_tf_albert.py
+4
-4
No files found.
transformers/modeling_albert.py
View file @
e85855f2
...
...
@@ -99,8 +99,23 @@ def load_tf_weights_in_albert(model, config, tf_checkpoint_path):
# Naming was changed to be more explicit
name
=
name
.
replace
(
"embeddings/attention"
,
"embeddings"
)
name
=
name
.
replace
(
"inner_group_"
,
"albert_layers/"
)
name
=
name
.
replace
(
"group_"
,
"albert_layer_groups/"
)
name
=
name
.
replace
(
"group_"
,
"albert_layer_groups/"
)
# Classifier
if
len
(
name
.
split
(
"/"
))
==
1
and
(
"output_bias"
in
name
or
"output_weights"
in
name
):
name
=
"classifier/"
+
name
# No ALBERT model currently handles the next sentence prediction task
if
"seq_relationship"
in
name
:
continue
name
=
name
.
split
(
'/'
)
# Ignore the gradients applied by the LAMB/ADAM optimizers.
if
"adam_m"
in
name
or
"adam_v"
in
name
or
"global_step"
in
name
:
logger
.
info
(
"Skipping {}"
.
format
(
"/"
.
join
(
name
)))
continue
pointer
=
model
for
m_name
in
name
:
if
re
.
fullmatch
(
r
'[A-Za-z]+_\d+'
,
m_name
):
...
...
transformers/modeling_tf_albert.py
View file @
e85855f2
...
...
@@ -31,10 +31,10 @@ import logging
logger
=
logging
.
getLogger
(
__name__
)
TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_MAP
=
{
'albert-base-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-base-tf_model.h5"
,
'albert-large-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-large-tf_model.h5"
,
'albert-xlarge-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-xlarge-tf_model.h5"
,
'albert-xxlarge-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-xxlarge-tf_model.h5"
,
'albert-base-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-base-
v1-
tf_model.h5"
,
'albert-large-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-large-
v1-
tf_model.h5"
,
'albert-xlarge-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-xlarge-
v1-
tf_model.h5"
,
'albert-xxlarge-v1'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-xxlarge-
v1-
tf_model.h5"
,
'albert-base-v2'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-base-v2-tf_model.h5"
,
'albert-large-v2'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-large-v2-tf_model.h5"
,
'albert-xlarge-v2'
:
"https://s3.amazonaws.com/models.huggingface.co/bert/albert-xlarge-v2-tf_model.h5"
,
...
...
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