remove fstrings
This commit is contained in:
committed by
Lysandre Debut
parent
3e7656f7ac
commit
73fe2e7385
@@ -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):
|
|||||||
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
|
||||||
|
|||||||
@@ -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):
|
|||||||
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user