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
18e1f751
Commit
18e1f751
authored
Dec 11, 2019
by
Julien Chaumond
Browse files
TF support
parent
31e5b5ff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
transformers/modeling_tf_utils.py
transformers/modeling_tf_utils.py
+6
-3
transformers/modeling_utils.py
transformers/modeling_utils.py
+2
-1
No files found.
transformers/modeling_tf_utils.py
View file @
18e1f751
...
...
@@ -24,7 +24,8 @@ import os
import
tensorflow
as
tf
from
.configuration_utils
import
PretrainedConfig
from
.file_utils
import
cached_path
,
WEIGHTS_NAME
,
TF_WEIGHTS_NAME
,
TF2_WEIGHTS_NAME
from
.file_utils
import
(
TF2_WEIGHTS_NAME
,
TF_WEIGHTS_NAME
,
WEIGHTS_NAME
,
cached_path
,
hf_bucket_url
,
is_remote_url
)
from
.modeling_tf_pytorch_utils
import
load_pytorch_checkpoint_in_tf2_model
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -257,12 +258,14 @@ class TFPreTrainedModel(tf.keras.Model):
raise
EnvironmentError
(
"Error no file named {} found in directory {} or `from_pt` set to False"
.
format
(
[
WEIGHTS_NAME
,
TF2_WEIGHTS_NAME
],
pretrained_model_name_or_path
))
elif
os
.
path
.
isfile
(
pretrained_model_name_or_path
):
elif
os
.
path
.
isfile
(
pretrained_model_name_or_path
)
or
is_remote_url
(
pretrained_model_name_or_path
)
:
archive_file
=
pretrained_model_name_or_path
elif
os
.
path
.
isfile
(
pretrained_model_name_or_path
+
".index"
):
archive_file
=
pretrained_model_name_or_path
+
".index"
else
:
archive_file
=
pretrained_model_name_or_path
archive_file
=
hf_bucket_url
(
pretrained_model_name_or_path
,
postfix
=
TF2_WEIGHTS_NAME
)
if
from_pt
:
raise
EnvironmentError
(
"Loading a TF model from a PyTorch checkpoint is not supported when using a model identifier name."
)
# redirect to the cache, if necessary
try
:
...
...
transformers/modeling_utils.py
View file @
18e1f751
...
...
@@ -372,7 +372,8 @@ class PreTrainedModel(nn.Module):
archive_file
=
pretrained_model_name_or_path
+
".index"
else
:
archive_file
=
hf_bucket_url
(
pretrained_model_name_or_path
,
postfix
=
WEIGHTS_NAME
)
# todo do we want to support TF checkpoints here?
if
from_tf
:
raise
EnvironmentError
(
"Loading a PyTorch model from a TF checkpoint is not supported when using a model identifier name."
)
# redirect to the cache, if necessary
try
:
...
...
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