Skip to content

Type Aliases

Types and type aliases used by Minnt.

minnt.AnyArray module-attribute

AnyArray: TypeAlias = Tensor | ndarray | list | tuple

A type alias for any array-like structure.

PyTorch tensors, NumPy arrays, lists, and tuples are supported.

minnt.DataFormat module-attribute

DataFormat: TypeAlias = Literal['HWC', 'CHW']

A type alias for image data format description.

minnt.HasCompute

Bases: Protocol

A protocol for objects that have a compute method of the following type:

def compute(self) -> float | torch.Tensor | np.ndarray:
    ...

compute

compute() -> float | Tensor | ndarray

Compute the value of the object.

minnt.Logs module-attribute

A dictionary of logs, with keys being the log names and values being the log values.

When the logs are returned by a minnt.TrainableModule or passed to a minnt.Callback, they are always evaluated to just float values.

minnt.Reduction module-attribute

Reduction: TypeAlias = Literal['mean', 'sum', 'none']

A type alias for reduction methods used in losses and metrics.

minnt.Tensor module-attribute

A type alias for a single tensor or a packed sequence of tensors.

minnt.TensorOrTensors module-attribute

TensorOrTensors: TypeAlias = (
    Tensor | tuple[Tensor, ...] | list[Tensor] | dict[str, Tensor] | Any
)

A type alias for a single tensor or a tensor structure.

While a tensor or a sequence of them is the most common, any type is allowed here to accomodate nested or completely custom data structures.