Generics#
- class Processor#
Base class for processing modules.
This class provides a basic structure for processing modules, including a forward method that defines how input data should be processed. Derived classes should implement the forward method to define their specific processing logic.
Signal Model#
The generic model for a processor is :
\[\mathbf{Y} = \mathbf{f}(\mathbf{X};\boldsymbol \theta) \]\(\mathbf{X}\) corresponds to the input data,
\(\mathbf{Y}\) corresponds to the output data,
\(\boldsymbol \theta\) corresponds to the processor parameters.
\(\mathbf{f}(.)\) is a multidimensional nonlinear function.
When a processor is called with input data, it automatically computes the output data by calling its
forward
method.Note
A processor is not necessarly fully deterministic. Some processor can also contain a stochastic part.
- forward(x: ndarray) ndarray #
Process the input data
- set_debug(debug=None)#
Change the debugging mode
- prepare(X: ndarray) ndarray #
Prepare the object before calling the forward method
- class Sequential(module_list: list, debug: bool = False, name: str = 'sequential', callbacks: ~typing.Dict[str | int, ~typing.Callable] | None = <factory>)#
A sequential container for processing modules.
This class allows to create complex chain by stacking \(L\) different processor modules. These processors are executed in the order they are added.
Signal Model#
Initialisation:
\[\mathbf{Y}_0 = \mathbf{X}\]Iterations. For \(l=0, \cdots, L-1\), perform the following assignement
\[\mathbf{Y}_{l+1} = \mathbf{f}_l(\mathbf{Y}_{l};\boldsymbol \theta_l)\]where \(\mathbf{f}_l()\) corresponds to the multidimensional function of the \(l^{th}\) processor.
The
forward
method returns the last output \(\mathbf{Y}_{L}\)Callbacks#
You can optionally provide a dictionary of callbacks via the
callbacks
attribute. These functions will be called after each processor executes, receiving that processor’s output as input. Keys of the dictionary correspond to processor names (processor.name
) in the chain.Attributes#
- module_listlist
Ordered list of processing modules to be executed sequentially.
- debugbool, optional
Enables debug mode if True (default is False).
- namestr, optional
Name of the sequential processor (default is ‘sequential’).
- callbacksdict, optional
Dictionary of callback functions called after each processor. Keys are processor names (str) or indices (int), values are callables accepting the processor output.
- set_debug(debug=None)#
Change the debugging mode
- profile_execution_time(X: ndarray)#
Start profiling
- forward(X: ndarray) ndarray #
Process the input data through all modules in the sequence.
- get_module_by_index(index: int)#
Retrieve a module from the module list by its index.
- get_module_by_name(module_name: str)#
Retrieve a module from the module list by its name.