Skip to content

Commit

Permalink
Use .compute() instead of ._compute() (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
qubvel authored May 1, 2024
1 parent c79651b commit dc6b5d0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions fine-tune-segformer.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,13 @@ def compute_metrics(eval_pred):
).argmax(dim=1)

pred_labels = logits_tensor.detach().cpu().numpy()
# currently using _compute instead of compute
# see this issue for more info: https://github.com/huggingface/evaluate/pull/328#issuecomment-1286866576
metrics = metric._compute(
predictions=pred_labels,
references=labels,
num_labels=len(id2label),
ignore_index=0,
reduce_labels=processor.do_reduce_labels,
)
metrics = metric.compute(
predictions=pred_labels,
references=labels,
num_labels=len(id2label),
ignore_index=0,
reduce_labels=processor.do_reduce_labels,
)

# add per category metrics as individual key-value pairs
per_category_accuracy = metrics.pop("per_category_accuracy").tolist()
Expand Down

0 comments on commit dc6b5d0

Please sign in to comment.