Module
Base class for deriving trainable modules
- class ivy.stateful.module.Module(device=None, v=None, build_mode='on_init', compile_on_next_step=False, store_vars=True, stateful=None, arg_stateful_idxs=None, kwarg_stateful_idxs=None, fallback_to_non_compiled=False, with_partial_v=False, devices=None, dtype=None)[source]
Bases:
ABC
- __init__(device=None, v=None, build_mode='on_init', compile_on_next_step=False, store_vars=True, stateful=None, arg_stateful_idxs=None, kwarg_stateful_idxs=None, fallback_to_non_compiled=False, with_partial_v=False, devices=None, dtype=None)[source]
Initialze Ivy layer, which is a stateful object consisting of trainable variables.
- Parameters
device – device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
v – Ivy container of trainable variables. Created internally by default.
build_mode – How the Module is built, either on initialization (now), explicitly by the user by calling build(), or the first time the __call__ method is run. Default is on initialization.
compile_on_next_step – Whether to compile the network on the next forward pass. Default is False.
store_vars – Whether or not to store the variables created. Default is True.
stateful – The constant id stateful items to track as part of the forward pass. Used when graph compiling, default is None.
arg_stateful_idxs – The nested argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is None.
kwarg_stateful_idxs – The nested keyword argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is None.
fallback_to_non_compiled – Whether to fall back to non-compiled forward call in the case that an error is raised during the compiled forward pass. Default is True.
with_partial_v – Whether to allow partial specification of variables. Default is False.
devices – devices on which to distribute the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
- build(*args, from_call=False, device=None, dtype=None, **kwargs)[source]
Build the internal layers and variables for this module.
- property build_mode
- property built