mllooper.Looper#
- class mllooper.Looper(modules: Dict[str, Union[Module, str]], **kwargs)[source]#
Bases:
ModuleA module which takes a list of other modules and loops over it.
A step on a Looper module is not a single iteration of the loop but the whole loop. That means a single step on a Looper is a loop that might run forever.
The state inside the loop is separated from the state outside the loop. The modules which the Looper loops over never see the state the lopper lives in.
- initialise(modules: Dict[str, Module])[source]#
Perform initialization steps of all modules in the loop.
Modules in the loop should not depend on modules outside the loop. Therefore the modules of the loop can only access other modules in the same loop. The given modules dictionary will be ignored.
- Parameters:
modules (Dict[str, Module]) – Dictionary of other modules which are already initialised
- inner_log(state: State)[source]#
Log information from the Looper and from all included modules.
- Parameters:
state (State) – The current state
- load_state_dict(state_dict: Dict[str, any], strict: bool = True)[source]#
Load the modules state from a dictionary.
- Parameters:
state_dict (Dict[str, any]) – The state dictionary to load
strict (bool) – If true rise an error on missing or additional keys in the state dict. If false these keys will be ignored.
- state_dict() Dict[str, Any][source]#
Return the state of the module as dictionary.
All items of the dictionary should be serializable by pickle.
- Returns:
The modules current state as dictionary
- Return type:
Dict[str, Any]