Module Class#
- class evox.Stateful[source]#
Base class for all evox modules.
This module allow easy managing of states.
All the constants (e.g. hyperparameters) are initialized in the
__init__, and mutated states are initialized in thesetupmethod.The
initmethod will automatically call thesetupof the current module and recursively callsetupmethods of all submodules.Currently, there are two special metadata that can be used to control the behavior of the module initialization: -
stack: If set to True, the module will be initialized multiple times, and the states will be stacked together. -nested: If set to True, the a list of modules, that is [module1, module2, …], will be iterated and initialized.- init(key=None, no_state=False, re_init=False)[source]#
Initialize this module and all submodules
This method should not be overwritten.
- Parameters:
key (Array | None) – A PRNGKey.
no_state (bool)
re_init (bool)
- Returns:
The state of this module and all submodules combined.
- Return type:
- parallel_init(key, num_copies, no_state=False)[source]#
Initialize multiple copies of this module in parallel
This method should not be overwritten.
- Parameters:
key (Array) – A PRNGKey.
num_copies (int) – The number of copies to be initialized
no_state (bool) – Whether to skip the state initialization
- Returns:
The state of this module and all submodules combined, and the last node_id
- Return type:
Tuple[State, int]