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
4a21c4d8
Commit
4a21c4d8
authored
Sep 26, 2019
by
thomwolf
Browse files
add warning if neither pt nor tf are found
parent
2967de06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
examples/run_tf_glue.py
examples/run_tf_glue.py
+3
-3
pytorch_transformers/__init__.py
pytorch_transformers/__init__.py
+5
-0
No files found.
examples/run_tf_glue.py
View file @
4a21c4d8
...
...
@@ -15,12 +15,12 @@ valid_dataset = valid_dataset.batch(64)
# Compile tf.keras model for training
learning_rate
=
tf
.
keras
.
optimizers
.
schedules
.
PolynomialDecay
(
2e-5
,
345
,
end_learning_rate
=
0
)
optimizer
=
tf
.
keras
.
optimizers
.
Adam
(
learning_rate
=
learning_rate
,
epsilon
=
1e-08
,
clipnorm
=
1.0
)
loss
=
tf
.
keras
.
losses
.
SparseCategoricalCrossentropy
(
from_logits
=
True
)
tf_model
.
compile
(
optimizer
=
tf
.
keras
.
optimizers
.
Adam
(
learning_rate
=
learning_rate
,
epsilon
=
1e-08
,
clipnorm
=
1.0
),
loss
=
loss
,
metrics
=
[
'sparse_categorical_accuracy'
])
tf_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
'sparse_categorical_accuracy'
])
# Train and evaluate using tf.keras.Model.fit()
tf_model
.
fit
(
train_dataset
,
epochs
=
3
,
steps_per_epoch
=
115
,
validation_data
=
valid_dataset
,
validation_steps
=
7
)
tf_model
.
fit
(
train_dataset
,
epochs
=
1
,
steps_per_epoch
=
115
,
validation_data
=
valid_dataset
,
validation_steps
=
7
)
# Save the model and load it in PyTorch
tf_model
.
save_pretrained
(
'./runs/'
)
...
...
pytorch_transformers/__init__.py
View file @
4a21c4d8
...
...
@@ -157,3 +157,8 @@ if is_tf_available() and is_torch_available():
load_tf2_checkpoint_in_pytorch_model
,
load_tf2_weights_in_pytorch_model
,
load_tf2_model_in_pytorch_model
)
if
not
is_tf_available
()
and
not
is_torch_available
():
logger
.
warning
(
"Neither PyTorch nor TensorFlow >= 2.0 have been found."
"Models won't be available and only tokenizers, configuration"
"and file/data utilities can be used."
)
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