ExactMatch
minnt.metrics.ExactMatch
Bases: Mean
Exact match metric implementation.
The elements to compare can be either tensors or generic iterables. When tensors are used,
the element_dims parameter can be specified to indicate which dimensions of the tensors
form an element for comparison; when iterables are used, the input one-dimensional sequences are
compared directly.
Source code in minnt/metrics/exact_match.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
__init__
Create the ExactMatch metric object.
Parameters:
-
element_dims(int | tuple[int], default:()) –If the values to compare are tensors, this parameter can be used to specify which dimensions of the tensors form an element for comparison.
Source code in minnt/metrics/exact_match.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
update
update(
y: Tensor | Iterable[Any],
y_true: Tensor | Iterable[Any],
sample_weights: Tensor | None = None,
) -> None
Update the exact match by comparing the given values.
The inputs can be either both tensors or both iterables. When they are both tensors,
the element_dims parameter can be used to specify which dimensions of the tensors
form an element for comparison; when they are both iterables, the elements are
compared directly.
Optional sample weight might be provided; if not, all values are weighted with 1.
Parameters:
-
y(Tensor | Iterable[Any]) –A tensor or an iterable of predicted values of the same shape as
y_true. -
y_true(Tensor | Iterable[Any]) –A tensor or an iterable of ground-truth targets of the same shape as
y. -
sample_weights(Tensor | None, default:None) –Optional sample weights. Their shape must be broadcastable to a prefix of the shape of
y(withelement_dimsdimensions removed, if specified).
Source code in minnt/metrics/exact_match.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |