generic#

The structural types defined within protocols.generic provide a helpful stepping stone for defining new AI problems. The generic structural types defined permit a specialization via concrete type parameters that specify expectations for the lower level primitives used in the specific AI problem. These primitive types specify the InputType, TargetType, and DatumMetadataType along with the structural/semantic expectations for each.

Warning

The protocols.generic module is an advanced part of MAITE that provides an extension point for defining new AI problems. Its use requires more advanced knowledge of the Python typing system. Further, it should not be used to type hint directly, as type hinting against a non-specialized generic type effectively bypasses useful type checking of those type parameters.

Use with care.

Note

Shape and semantic expectations specified for a primitive (e.g., image classification specifies an ArrayLike input type with (C, H, W) shape semantics that is expected by Dataset, DataLoader, Model, and Augmentation) are not enforceable by static type checkers. Opt-in runtime verification is being actively explored to provide additional safety beyond what is possible via the Python typing spec.

primitives#

protocols.ArrayLike

Object coercible into a NumPy ndarray (alias of numpy.typing.ArrayLike)

protocols.DatumMetadata

Metadata associated with a single datum.

components#

protocols.generic.Augmentation(*args, **kwargs)

Generic version of a protocol that specifies a batch-level perturbation to data.

protocols.generic.DataLoader(*args, **kwargs)

Generic version of a protocol that specifies batch-level access to a data source.

protocols.generic.Dataset(*args, **kwargs)

Generic version of a protocol that specifies datum-level random access to a data source.

protocols.generic.Metric(*args, **kwargs)

Generic version of a protocol that specifies a model/data alignment calculation behavior on data batches.

protocols.generic.Model(*args, **kwargs)

Generic version of a protocol that specifies inference behavior on data batches.