kaira.models.generic.SequentialModel

Inheritance diagram of SequentialModel

Inheritance diagram for SequentialModel

class kaira.models.generic.SequentialModel(steps: Sequence[Callable] | None = None, *args: Any, **kwargs: Any)[source]

Bases: ConfigurableModel

A model that processes steps sequentially.

Each step receives the output of the previous step as its input.

Methods

__init__

Initialize the sequential model.

add_step

Add a processing step to the model.

forward

Execute the model sequentially on the input data.

remove_step

Remove a processing step from the model.

__init__(steps: Sequence[Callable] | None = None, *args: Any, **kwargs: Any)[source]

Initialize the sequential model.

Parameters:
  • steps – Optional initial list of processing steps

  • *args – Variable positional arguments passed to the base class.

  • **kwargs – Variable keyword arguments passed to the base class.

forward(input_data: Any, *args: Any, **kwargs: Any) Any[source]

Execute the model sequentially on the input data.

Parameters:
  • input_data – The initial data to process

  • *args – Additional positional arguments passed to each step.

  • **kwargs – Additional keyword arguments passed to each step.

Returns:

The final result after passing through all steps

add_step(step: Callable) ConfigurableModel

Add a processing step to the model.

Parameters:

step – A callable that will be added to the processing pipeline. Must accept and return tensor-like objects.

Returns:

Self for method chaining

remove_step(index: int) ConfigurableModel

Remove a processing step from the model.

Parameters:

index – The index of the step to remove

Returns:

Self for method chaining

Raises:

IndexError – If the index is out of range