Migrate metric to Evaluate in Pytorch examples (#18369)

* Migrate metric to Evaluate in pytorch examples

* Remove unused imports
This commit is contained in:
atturaioe
2022-08-01 14:40:25 +03:00
committed by GitHub
parent 25ec12eaf7
commit 1f84399171
25 changed files with 72 additions and 49 deletions

View File

@@ -26,6 +26,7 @@ import datasets
import numpy as np
from datasets import DatasetDict, load_dataset
import evaluate
import transformers
from transformers import (
AutoConfig,
@@ -315,7 +316,7 @@ def main():
id2label[str(i)] = label
# Load the accuracy metric from the datasets package
metric = datasets.load_metric("accuracy")
metric = evaluate.load("accuracy")
# Define our compute_metrics function. It takes an `EvalPrediction` object (a namedtuple with
# `predictions` and `label_ids` fields) and has to return a dictionary string to float.