Skip to content

miniml.nn.compose

Identity

Bases: MiniMLModel

A MiniML model that returns its input unchanged or scaled.

__init__(scale=1.0)

Initialize the Identity model.

Parameters:

Name Type Description Default
scale float

The scale factor to apply to the input. Defaults to 1.0.

1.0

Take

Bases: MiniMLModel

A MiniML model that takes specific indices from the input array along a given axis.

__init__(indices, axis=-1)

Initialize the Take model.

Parameters:

Name Type Description Default
indices list[int] | int

The indices to take from the input array.

required
axis int

The axis along which to take the indices. Defaults to -1.

-1

Stack

Bases: MiniMLModel

A MiniML model that stacks multiple MiniML models sequentially.

__init__(models, loss=None)

Initialize the Stack model.

Parameters:

Name Type Description Default
models list[MiniMLModel]

The models to stack.

required
loss LossFunction

The loss function to use. Defaults to None.

None

Raises:

Type Description
ValueError

If the model list is empty.

Parallel

Bases: MiniMLModel

A MiniML model that applies multiple MiniML models in parallel and sums or concatenates their outputs.

__init__(models, mode, concat_axis=-1, loss=None)

Initialize the Parallel model.

Parameters:

Name Type Description Default
models list[MiniMLModel]

The models to apply in parallel.

required
mode Literal['sum', 'concat']

The mode of combining outputs.

required
concat_axis int

The axis to concatenate along if mode is "concat". Defaults to -1.

-1
loss LossFunction | None

The loss function to use. Defaults to None.

None

Raises:

Type Description
ValueError

If models list is empty or mode is invalid.

ValueError

If mode is not a valid option.