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
528c288f
Commit
528c288f
authored
Sep 27, 2019
by
thomwolf
Browse files
clean up run_tf_glue
parent
702f5898
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
8 deletions
+0
-8
examples/run_tf_glue.py
examples/run_tf_glue.py
+0
-8
No files found.
examples/run_tf_glue.py
View file @
528c288f
...
@@ -23,12 +23,6 @@ model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
...
@@ -23,12 +23,6 @@ model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
history
=
model
.
fit
(
train_dataset
,
epochs
=
2
,
steps_per_epoch
=
115
,
history
=
model
.
fit
(
train_dataset
,
epochs
=
2
,
steps_per_epoch
=
115
,
validation_data
=
valid_dataset
,
validation_steps
=
7
)
validation_data
=
valid_dataset
,
validation_steps
=
7
)
>>>
Train
for
115
steps
,
validate
for
7
steps
>>>
Epoch
1
/
2
>>>
115
/
115
[
==============================
]
-
53
s
459
ms
/
step
-
loss
:
0.6033
-
accuracy
:
0.6712
-
val_loss
:
0.4964
-
val_accuracy
:
0.7647
>>>
Epoch
2
/
2
>>>
115
/
115
[
==============================
]
-
33
s
289
ms
/
step
-
loss
:
0.4141
-
accuracy
:
0.8160
-
val_loss
:
0.3914
-
val_accuracy
:
0.8382
# Load the TensorFlow model in PyTorch for inspection
# Load the TensorFlow model in PyTorch for inspection
model
.
save_pretrained
(
'./save/'
)
model
.
save_pretrained
(
'./save/'
)
pytorch_model
=
BertForSequenceClassification
.
from_pretrained
(
'./save/'
,
from_tf
=
True
)
pytorch_model
=
BertForSequenceClassification
.
from_pretrained
(
'./save/'
,
from_tf
=
True
)
...
@@ -44,5 +38,3 @@ pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
...
@@ -44,5 +38,3 @@ pred_1 = pytorch_model(**inputs_1)[0].argmax().item()
pred_2
=
pytorch_model
(
**
inputs_2
)[
0
].
argmax
().
item
()
pred_2
=
pytorch_model
(
**
inputs_2
)[
0
].
argmax
().
item
()
print
(
"sentence_1 is"
,
"a paraphrase"
if
pred_1
else
"not a paraphrase"
,
"of sentence_0"
)
print
(
"sentence_1 is"
,
"a paraphrase"
if
pred_1
else
"not a paraphrase"
,
"of sentence_0"
)
print
(
"sentence_2 is"
,
"a paraphrase"
if
pred_2
else
"not a paraphrase"
,
"of sentence_0"
)
print
(
"sentence_2 is"
,
"a paraphrase"
if
pred_2
else
"not a paraphrase"
,
"of sentence_0"
)
>>>
sentence_1
is
a
paraphrase
of
sentence_0
>>>
sentence_2
is
not
a
paraphrase
of
sentence_0
\ No newline at end of file
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