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
b54de837
Commit
b54de837
authored
Nov 02, 2018
by
VictorSanh
Browse files
Quick fix on eval accuracy
parent
1d53f9cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
run_classifier_pytorch.py
run_classifier_pytorch.py
+5
-2
No files found.
run_classifier_pytorch.py
View file @
b54de837
...
@@ -548,6 +548,7 @@ def main():
...
@@ -548,6 +548,7 @@ def main():
model
.
eval
()
model
.
eval
()
eval_loss
=
0
eval_loss
=
0
eval_accuracy
=
0
eval_accuracy
=
0
nb_eval_examples
=
0
for
input_ids
,
input_mask
,
segment_ids
,
label_ids
in
eval_dataloader
:
for
input_ids
,
input_mask
,
segment_ids
,
label_ids
in
eval_dataloader
:
input_ids
=
input_ids
.
to
(
device
)
input_ids
=
input_ids
.
to
(
device
)
input_mask
=
input_mask
.
float
().
to
(
device
)
input_mask
=
input_mask
.
float
().
to
(
device
)
...
@@ -562,9 +563,11 @@ def main():
...
@@ -562,9 +563,11 @@ def main():
eval_loss
+=
tmp_eval_loss
.
item
()
eval_loss
+=
tmp_eval_loss
.
item
()
eval_accuracy
+=
tmp_eval_accuracy
eval_accuracy
+=
tmp_eval_accuracy
nb_eval_examples
+=
input_ids
.
size
(
0
)
eval_loss
=
eval_loss
/
len
(
eval_dataloader
)
eval_loss
=
eval_loss
/
nb_eval_examples
#
len(eval_dataloader)
eval_accuracy
=
eval_accuracy
/
len
(
eval_dataloader
)
eval_accuracy
=
eval_accuracy
/
nb_eval_examples
#
len(eval_dataloader)
result
=
{
'eval_loss'
:
eval_loss
,
result
=
{
'eval_loss'
:
eval_loss
,
'eval_accuracy'
:
eval_accuracy
,
'eval_accuracy'
:
eval_accuracy
,
...
...
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