Spaces:
Running
Running
fix input format conversion
Browse files
README.md
CHANGED
|
@@ -24,8 +24,8 @@ https://torchmetrics.readthedocs.io/en/stable/classification/calibration_error.h
|
|
| 24 |
|
| 25 |
### Inputs
|
| 26 |
*List all input arguments in the format below*
|
| 27 |
-
- **
|
| 28 |
-
- **references** *(
|
| 29 |
|
| 30 |
### Output Values
|
| 31 |
|
|
|
|
| 24 |
|
| 25 |
### Inputs
|
| 26 |
*List all input arguments in the format below*
|
| 27 |
+
- **predictions** *(float32): predictions (after softmax). They must have a shape (N,C,...) if multiclass, or (N,...) if binary.*
|
| 28 |
+
- **references** *(int64): reference for each prediction, with a shape (N,...).*
|
| 29 |
|
| 30 |
### Output Values
|
| 31 |
|
ece.py
CHANGED
|
@@ -16,7 +16,7 @@ from typing import Dict
|
|
| 16 |
|
| 17 |
import evaluate
|
| 18 |
import datasets
|
| 19 |
-
from torch import
|
| 20 |
from torchmetrics.functional.classification.calibration_error import (
|
| 21 |
binary_calibration_error,
|
| 22 |
multiclass_calibration_error,
|
|
@@ -106,10 +106,8 @@ class ECE(evaluate.Metric):
|
|
| 106 |
be used as "num_classes".
|
| 107 |
"""
|
| 108 |
# Convert the input
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
if isinstance(references, ndarray):
|
| 112 |
-
references = from_numpy(references)
|
| 113 |
|
| 114 |
max_label = amax(references, list(range(references.dim())))
|
| 115 |
if max_label > 1 and "num_classes" not in kwargs:
|
|
|
|
| 16 |
|
| 17 |
import evaluate
|
| 18 |
import datasets
|
| 19 |
+
from torch import Tensor, LongTensor, amax
|
| 20 |
from torchmetrics.functional.classification.calibration_error import (
|
| 21 |
binary_calibration_error,
|
| 22 |
multiclass_calibration_error,
|
|
|
|
| 106 |
be used as "num_classes".
|
| 107 |
"""
|
| 108 |
# Convert the input
|
| 109 |
+
predictions = Tensor(predictions)
|
| 110 |
+
references = LongTensor(references)
|
|
|
|
|
|
|
| 111 |
|
| 112 |
max_label = amax(references, list(range(references.dim())))
|
| 113 |
if max_label > 1 and "num_classes" not in kwargs:
|