tfaip.evaluator

EvaluatorBase

Implementation of a Evaluator

that can be used to define additional metrics computed during LAV.

class tfaip.evaluator.evaluator.EvaluatorBase(params: TP)

Bases: Generic[tfaip.evaluator.evaluator.TP]

An EvaluatorBase allows to implement custom metrics for a scenario in pure python. It will be applied after the post_proc pipeline (instead of any other metric).

Overwrite __enter__ to reset the internal states, update_state to update the metrics, and result to yield the results.

Optionally overwrite EvaluatorParams if needed and pass as Generic type.

See also

  • TrainerParams.lav_every_n

  • LAV

classmethod params_cls()Type[TP]
classmethod default_params()TP
__init__(params: TP)

Initialize self. See help(type(self)) for accurate signature.

update_state(sample: tfaip.data.pipeline.definitions.Sample)NoReturn

Method called after a sample is processed by the model and post_proc to update the internal state of all metrics :param sample: unbatched sample (possibly with paddings!)

See also

tf.keras.metrics.Metric.update_state

result()Dict[str, Union[numpy.ndarray, int, numpy.int8, numpy.int16, numpy.int32, numpy.int64, float, numpy.float16, numpy.float32, numpy.float64, bool]]

Method to return the result of the evaluator as dict :returns: The metric results

See also

tf.keras.metrics.Metric.result

EvaluatorParams

Definition of the base parameters for the EvaluatorBase

class tfaip.evaluator.params.EvaluatorParams

Bases: object

Params for the EvaluatorBase.

See also

EvaluatorBase

__init__()None

Initialize self. See help(type(self)) for accurate signature.

classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False)A
classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw)A
classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None)dataclasses_json.mm.SchemaF[A]
to_dict(encode_json=False)Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw)str