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
8a4e90ff
Commit
8a4e90ff
authored
Mar 17, 2019
by
Ananya Harsh Jha
Browse files
corrected folder creation error for MNLI-MM, verified GLUE results
parent
e0bf01d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
examples/run_classifier.py
examples/run_classifier.py
+8
-3
No files found.
examples/run_classifier.py
View file @
8a4e90ff
...
@@ -908,7 +908,7 @@ def main():
...
@@ -908,7 +908,7 @@ def main():
with
torch
.
no_grad
():
with
torch
.
no_grad
():
logits
=
model
(
input_ids
,
segment_ids
,
input_mask
,
labels
=
None
)
logits
=
model
(
input_ids
,
segment_ids
,
input_mask
,
labels
=
None
)
# create eval loss and other metric required by the task
# create eval loss and other metric required by the task
if
output_mode
==
"classification"
:
if
output_mode
==
"classification"
:
loss_fct
=
CrossEntropyLoss
()
loss_fct
=
CrossEntropyLoss
()
...
@@ -944,12 +944,17 @@ def main():
...
@@ -944,12 +944,17 @@ def main():
for
key
in
sorted
(
result
.
keys
()):
for
key
in
sorted
(
result
.
keys
()):
logger
.
info
(
" %s = %s"
,
key
,
str
(
result
[
key
]))
logger
.
info
(
" %s = %s"
,
key
,
str
(
result
[
key
]))
writer
.
write
(
"%s = %s
\n
"
%
(
key
,
str
(
result
[
key
])))
writer
.
write
(
"%s = %s
\n
"
%
(
key
,
str
(
result
[
key
])))
# hack for MNLI-MM
# hack for MNLI-MM
if
task_name
==
"mnli"
:
if
task_name
==
"mnli"
:
task_name
=
"mnli-mm"
task_name
=
"mnli-mm"
processor
=
processors
[
task_name
]()
processor
=
processors
[
task_name
]()
if
os
.
path
.
exists
(
args
.
output_dir
+
'-MM'
)
and
os
.
listdir
(
args
.
output_dir
+
'-MM'
)
and
args
.
do_train
:
raise
ValueError
(
"Output directory ({}) already exists and is not empty."
.
format
(
args
.
output_dir
))
if
not
os
.
path
.
exists
(
args
.
output_dir
+
'-MM'
):
os
.
makedirs
(
args
.
output_dir
+
'-MM'
)
eval_examples
=
processor
.
get_dev_examples
(
args
.
data_dir
)
eval_examples
=
processor
.
get_dev_examples
(
args
.
data_dir
)
eval_features
=
convert_examples_to_features
(
eval_features
=
convert_examples_to_features
(
eval_examples
,
label_list
,
args
.
max_seq_length
,
tokenizer
,
output_mode
)
eval_examples
,
label_list
,
args
.
max_seq_length
,
tokenizer
,
output_mode
)
...
@@ -990,7 +995,7 @@ def main():
...
@@ -990,7 +995,7 @@ def main():
else
:
else
:
preds
[
0
]
=
np
.
append
(
preds
[
0
]
=
np
.
append
(
preds
[
0
],
logits
.
detach
().
cpu
().
numpy
(),
axis
=
0
)
preds
[
0
],
logits
.
detach
().
cpu
().
numpy
(),
axis
=
0
)
eval_loss
=
eval_loss
/
nb_eval_steps
eval_loss
=
eval_loss
/
nb_eval_steps
preds
=
preds
[
0
]
preds
=
preds
[
0
]
preds
=
np
.
argmax
(
preds
,
axis
=
1
)
preds
=
np
.
argmax
(
preds
,
axis
=
1
)
...
...
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