espnet3.contract.kinds.number.NumberKind
Less than 1 minute
espnet3.contract.kinds.number.NumberKind
class espnet3.contract.kinds.number.NumberKind
Bases: Kind
number: a real number, not bool; does not join.
What a metric’s declared outputs hold: one scalar per result key, such as {"WER": 4.3}.
####### Examples
>>> NumberKind().check(4.3, Field("WER", "number"), model, output=True)
4.3check(value, field, model, , output)
Require a real number, excluding bool.
- Parameters:
- value – What the caller gave, or what the hook returned.
- field – The declaration, for the name in the error.
- model – Unused; a number needs nothing from the model.
- output – Whether
valueis a hook’s result.
- Returns:
valueitself. - Raises:TypeError – If
valueis not a real number (numbers.Real), or is aboolornp.bool_.
####### Examples
>>> NumberKind().check(4.3, Field("WER", "number"), model, output=True)
4.3
>>> NumberKind().check(
... np.float32(4.3), Field("WER", "number"), model, output=True
... )
np.float32(4.3)
>>> NumberKind().check(True, Field("WER", "number"), model, output=True)
Traceback (most recent call last):
TypeError: 'WER' returned as bool, must be a real number