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
73fe2e73
Commit
73fe2e73
authored
Nov 05, 2019
by
VictorSanh
Committed by
Lysandre Debut
Nov 27, 2019
Browse files
remove fstrings
parent
3e7656f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
examples/run_xnli.py
examples/run_xnli.py
+2
-2
transformers/data/processors/xnli.py
transformers/data/processors/xnli.py
+2
-2
No files found.
examples/run_xnli.py
View file @
73fe2e73
...
@@ -248,7 +248,7 @@ def evaluate(args, model, tokenizer, prefix=""):
...
@@ -248,7 +248,7 @@ def evaluate(args, model, tokenizer, prefix=""):
if
args
.
output_mode
==
"classification"
:
if
args
.
output_mode
==
"classification"
:
preds
=
np
.
argmax
(
preds
,
axis
=
1
)
preds
=
np
.
argmax
(
preds
,
axis
=
1
)
else
:
else
:
raise
ValueError
(
f
'No other `output_mode` for XNLI.'
)
raise
ValueError
(
'No other `output_mode` for XNLI.'
)
result
=
compute_metrics
(
eval_task
,
preds
,
out_label_ids
)
result
=
compute_metrics
(
eval_task
,
preds
,
out_label_ids
)
results
.
update
(
result
)
results
.
update
(
result
)
...
@@ -305,7 +305,7 @@ def load_and_cache_examples(args, task, tokenizer, evaluate=False):
...
@@ -305,7 +305,7 @@ def load_and_cache_examples(args, task, tokenizer, evaluate=False):
if
output_mode
==
"classification"
:
if
output_mode
==
"classification"
:
all_labels
=
torch
.
tensor
([
f
.
label
for
f
in
features
],
dtype
=
torch
.
long
)
all_labels
=
torch
.
tensor
([
f
.
label
for
f
in
features
],
dtype
=
torch
.
long
)
else
:
else
:
raise
ValueError
(
f
'No other `output_mode` for XNLI.'
)
raise
ValueError
(
'No other `output_mode` for XNLI.'
)
dataset
=
TensorDataset
(
all_input_ids
,
all_attention_mask
,
all_token_type_ids
,
all_labels
)
dataset
=
TensorDataset
(
all_input_ids
,
all_attention_mask
,
all_token_type_ids
,
all_labels
)
return
dataset
return
dataset
...
...
transformers/data/processors/xnli.py
View file @
73fe2e73
...
@@ -36,7 +36,7 @@ class XnliProcessor(DataProcessor):
...
@@ -36,7 +36,7 @@ class XnliProcessor(DataProcessor):
def
get_train_examples
(
self
,
data_dir
):
def
get_train_examples
(
self
,
data_dir
):
"""See base class."""
"""See base class."""
lg
=
self
.
language
if
self
.
train_language
is
None
else
self
.
train_language
lg
=
self
.
language
if
self
.
train_language
is
None
else
self
.
train_language
lines
=
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
f
"XNLI-MT-1.0/multinli/multinli.train.
{
lg
}
.tsv"
))
lines
=
self
.
_read_tsv
(
os
.
path
.
join
(
data_dir
,
"XNLI-MT-1.0/multinli/multinli.train.{lg}.tsv"
.
format
(
lg
)
))
examples
=
[]
examples
=
[]
for
(
i
,
line
)
in
enumerate
(
lines
):
for
(
i
,
line
)
in
enumerate
(
lines
):
if
i
==
0
:
if
i
==
0
:
...
@@ -78,7 +78,7 @@ def xnli_compute_metrics(task_name, preds, labels):
...
@@ -78,7 +78,7 @@ def xnli_compute_metrics(task_name, preds, labels):
if
task_name
==
"xnli"
:
if
task_name
==
"xnli"
:
return
{
"acc"
:
simple_accuracy
(
preds
,
labels
)}
return
{
"acc"
:
simple_accuracy
(
preds
,
labels
)}
else
:
else
:
raise
ValueError
(
f
'
{
task_name
}
is not a supported task.'
)
raise
ValueError
(
'{} is not a supported task.'
.
format
(
task_name
)
)
xnli_processors
=
{
xnli_processors
=
{
"xnli"
:
XnliProcessor
,
"xnli"
:
XnliProcessor
,
...
...
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