Block Module
Abstract Block
Base block class
- class lava.lib.dl.slayer.block.base.AbstractAffine(neuron_params, in_neurons, out_neurons, weight_scale=1, weight_norm=False, pre_hook_fx=None, dynamics=True, mask=None, count_log=False)
Bases:
ModuleAbstract affine transform class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
dynamics (bool, optional) – flag to enable neuron dynamics. If False, only the dendrite current is returned. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractAverage(num_outputs, count_log=False)
Bases:
ModuleAbstract average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractConv(neuron_params, in_features, out_features, kernel_size, stride=1, padding=0, dilation=1, groups=1, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay=False, delay_shift=True, count_log=False)
Bases:
ModuleAbstract convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input must be in
NCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractConvT(neuron_params, in_features, out_features, kernel_size, stride=1, padding=0, dilation=1, groups=1, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay=False, delay_shift=True, count_log=False)
Bases:
ModuleAbstract convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractDense(neuron_params, in_neurons, out_neurons, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay=False, delay_shift=True, mask=None, count_log=False)
Bases:
ModuleAbstract dense block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractFlatten(count_log=False)
Bases:
ModuleAbstract flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- class lava.lib.dl.slayer.block.base.AbstractInput(neuron_params=None, weight=None, bias=None, delay_shift=True, count_log=False)
Bases:
ModuleAbstract input block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractKWTA(neuron_params, in_neurons, out_neurons, num_winners, self_excitation=0.5, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay_shift=True, requires_grad=True, count_log=False)
Bases:
ModuleAbstract K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- clamp()
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractPool(neuron_params, kernel_size, stride=None, padding=0, dilation=1, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay=False, delay_shift=True, count_log=False)
Bases:
ModuleAbstract input block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input must be in
NCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractRecurrent(neuron_params, in_neurons, out_neurons, weight_scale=1, weight_norm=False, pre_hook_fx=None, requires_grad=True, delay=False, delay_shift=True, count_log=False)
Bases:
ModuleAbstract recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractResidual(*args, **kwargs)
Bases:
Module
- class lava.lib.dl.slayer.block.base.AbstractTimeDecimation(factor, count_log=False)
Bases:
ModuleAbstract time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
Forward computation method. The input can be either of
NCTorNCHWTformat.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractUnpool(neuron_params, kernel_size, stride=None, padding=0, dilation=1, weight_scale=1, weight_norm=False, pre_hook_fx=None, delay=False, delay_shift=True, count_log=False)
Bases:
ModuleAbstract Unpool block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
- property shape
Shape of the block.
- lava.lib.dl.slayer.block.base.step_delay(module, x)
Step delay computation. This simulates the 1 timestep delay needed for communication between layers.
- Parameters:
module (module) – python module instance
x (torch.tensor) – Tensor data to be delayed.
CUrrent BAsed Leaky Integrate and Fire (CUBA) Block
CUBA-LIF layer blocks
- class lava.lib.dl.slayer.block.cuba.AbstractCuba(*args, **kwargs)
Bases:
ModuleAbstract block class for Current Based Leaky Integrator neuron. This should never be instantiated on it’s own.
- class lava.lib.dl.slayer.block.cuba.Affine(*args, **kwargs)
Bases:
AbstractCuba,AbstractAffineCUBA LIF affine transform class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
dynamics (bool, optional) – flag to enable neuron dynamics. If False, only the dendrite current is returned. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Average(*args, **kwargs)
Bases:
AbstractAverageCUBA LIF average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Conv(*args, **kwargs)
Bases:
AbstractCuba,AbstractConvCUBA LIF convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.ConvT(*args, **kwargs)
Bases:
AbstractCuba,AbstractConvTCUBA LIF convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Dense(*args, **kwargs)
Bases:
AbstractCuba,AbstractDenseCUBA LIF dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Flatten(*args, **kwargs)
Bases:
AbstractFlattenCUBA LIF flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Input(*args, **kwargs)
Bases:
AbstractCuba,AbstractInputCUBA LIF input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.KWTA(*args, **kwargs)
Bases:
AbstractCuba,AbstractKWTACUBA LIF K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Pool(*args, **kwargs)
Bases:
AbstractCuba,AbstractPoolCUBA LIF input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Recurrent(*args, **kwargs)
Bases:
AbstractCuba,AbstractRecurrentCUBA LIF recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationCUBA LIF time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.cuba.Unpool(*args, **kwargs)
Bases:
AbstractCuba,AbstractUnpoolCUBA LIF Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of CUBA LIF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Resonate and Fire (R&F) Block
Resonate and Fire layer blocks.
- class lava.lib.dl.slayer.block.rf.AbstractRF(*args, **kwargs)
Bases:
ModuleAbstract Resonate and Fire block class. This should never be instantiated on it’s own.
- class lava.lib.dl.slayer.block.rf.Affine(*args, **kwargs)
Bases:
AbstractRF,AbstractAffineResonate & Fire affine transform class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
dynamics (bool, optional) – flag to enable neuron dynamics. If False, only the dendrite current is returned. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Average(*args, **kwargs)
Bases:
AbstractAverageResonate & Fire average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Conv(*args, **kwargs)
Bases:
AbstractRF,AbstractConvResonate & Fire convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.ConvT(*args, **kwargs)
Bases:
AbstractRF,AbstractConvTResonate & Fire convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Dense(*args, **kwargs)
Bases:
AbstractRF,AbstractDenseResonate & Fire dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Flatten(*args, **kwargs)
Bases:
AbstractFlattenResonate & Fire flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Input(*args, **kwargs)
Bases:
AbstractRF,AbstractInputResonate & Fire input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.KWTA(*args, **kwargs)
Bases:
AbstractRF,AbstractKWTAResonate & Fire K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Pool(*args, **kwargs)
Bases:
AbstractRF,AbstractPoolResonate & Fire input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Recurrent(*args, **kwargs)
Bases:
AbstractRF,AbstractRecurrentResonate & Fire recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationResonate & Fire time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf.Unpool(*args, **kwargs)
Bases:
AbstractRF,AbstractUnpoolResonate & Fire Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Resonate and Fire Izhikevich (R&F Iz) Block
Resonate and Fire - Izhikevich layer blocks.
- class lava.lib.dl.slayer.block.rf_iz.AbstractRFIz(*args, **kwargs)
Bases:
ModuleAbstract Resonate and Fire - Izhikevich block class. This should never be instantiated on it’s own.
- class lava.lib.dl.slayer.block.rf_iz.Affine(*args, **kwargs)
Bases:
AbstractRFIz,AbstractAffineResonate & Fire Izhikevich affine transform class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
dynamics (bool, optional) – flag to enable neuron dynamics. If False, only the dendrite current is returned. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Average(*args, **kwargs)
Bases:
AbstractAverageResonate & Fire Izhikevich average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Conv(*args, **kwargs)
Bases:
AbstractRFIz,AbstractConvResonate & Fire Izhikevich convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.ConvT(*args, **kwargs)
Bases:
AbstractRFIz,AbstractConvTResonate & Fire Izhikevich convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Dense(*args, **kwargs)
Bases:
AbstractRFIz,AbstractDenseResonate & Fire Izhikevich dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Flatten(*args, **kwargs)
Bases:
AbstractFlattenResonate & Fire Izhikevich flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Input(*args, **kwargs)
Bases:
AbstractRFIz,AbstractInputResonate & Fire Izhikevich input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.KWTA(*args, **kwargs)
Bases:
AbstractRFIz,AbstractKWTAResonate & Fire Izhikevich K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Pool(*args, **kwargs)
Bases:
AbstractRFIz,AbstractPoolResonate & Fire Izhikevich input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Recurrent(*args, **kwargs)
Bases:
AbstractRFIz,AbstractRecurrentResonate & Fire Izhikevich recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationResonate & Fire Izhikevich time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.rf_iz.Unpool(*args, **kwargs)
Bases:
AbstractRFIz,AbstractUnpoolResonate & Fire Izhikevich Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of RF-Izhikevich neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Adaptive Leaky Integrate and Fire (ALIF) Block
Adaptive Leaky Integrate and Fire block layers.
- class lava.lib.dl.slayer.block.alif.AbstractALIF(*args, **kwargs)
Bases:
ModuleAbstract Leaky Integrae and Fire block. This should never be instantiated on it’s own.
- class lava.lib.dl.slayer.block.alif.Average(*args, **kwargs)
Bases:
AbstractAverageAdaptive LIF average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Conv(*args, **kwargs)
Bases:
AbstractALIF,AbstractConvAdaptive LIF convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.ConvT(*args, **kwargs)
Bases:
AbstractALIF,AbstractConvTAdaptive LIF convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Dense(*args, **kwargs)
Bases:
AbstractALIF,AbstractDenseAdaptive LIF dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Flatten(*args, **kwargs)
Bases:
AbstractFlattenAdaptive LIF flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Input(*args, **kwargs)
Bases:
AbstractALIF,AbstractInputAdaptive LIF input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.KWTA(*args, **kwargs)
Bases:
AbstractALIF,AbstractKWTAAdaptive LIF K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Pool(*args, **kwargs)
Bases:
AbstractALIF,AbstractPoolAdaptive LIF input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Recurrent(*args, **kwargs)
Bases:
AbstractALIF,AbstractRecurrentAdaptive LIF recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationAdaptive LIF time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.alif.Unpool(*args, **kwargs)
Bases:
AbstractALIF,AbstractUnpoolAdaptive LIF Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive LIF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Adaptive Resonate and Fire (Ad R&F) Block
Adaptive Resonate and Fire - Phase Threshold layer
- class lava.lib.dl.slayer.block.adrf.AbstractADRF(*args, **kwargs)
Bases:
ModuleAbstract Adaptive Resonate and Fire block. This should never be instantiated on its own.
- class lava.lib.dl.slayer.block.adrf.Average(*args, **kwargs)
Bases:
AbstractAverageAdaptive Resonate & Fire average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Conv(*args, **kwargs)
Bases:
AbstractADRF,AbstractConvAdaptive Resonate & Fire convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.ConvT(*args, **kwargs)
Bases:
AbstractADRF,AbstractConvTAdaptive Resonate & Fire convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Dense(*args, **kwargs)
Bases:
AbstractADRF,AbstractDenseAdaptive Resonate & Fire dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Flatten(*args, **kwargs)
Bases:
AbstractFlattenAdaptive Resonate & Fire flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Input(*args, **kwargs)
Bases:
AbstractADRF,AbstractInputAdaptive Resonate & Fire input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.KWTA(*args, **kwargs)
Bases:
AbstractADRF,AbstractKWTAAdaptive Resonate & Fire K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Pool(*args, **kwargs)
Bases:
AbstractADRF,AbstractPoolAdaptive Resonate & Fire input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Recurrent(*args, **kwargs)
Bases:
AbstractADRF,AbstractRecurrentAdaptive Resonate & Fire recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationAdaptive Resonate & Fire time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf.Unpool(*args, **kwargs)
Bases:
AbstractADRF,AbstractUnpoolAdaptive Resonate & Fire Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Adaptive Resonate and Fire Izhikevich (Ad R&F Iz) Block
Adaptive Resonate and Fire - Izhikevich layer blocks
- class lava.lib.dl.slayer.block.adrf_iz.AbstractADRFIZ(*args, **kwargs)
Bases:
ModuleAbstract Adaptive Resonate and Fire - Izhikevich block. This should never be instantiated on its own.
- class lava.lib.dl.slayer.block.adrf_iz.Average(*args, **kwargs)
Bases:
AbstractAverageAdaptive Resonate & Fire Izhikevich average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Conv(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractConvAdaptive Resonate & Fire Izhikevich convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.ConvT(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractConvTAdaptive Resonate & Fire Izhikevich convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Dense(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractDenseAdaptive Resonate & Fire Izhikevich dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Flatten(*args, **kwargs)
Bases:
AbstractFlattenAdaptive Resonate & Fire Izhikevich flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Input(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractInputAdaptive Resonate & Fire Izhikevich input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.KWTA(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractKWTAAdaptive Resonate & Fire Izhikevich K-Winner-Takes-All block class. This should never be instantiated on its own. The formulation is described as below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1] + \alpha\,(N-2K)\right)\\ \mathbf{R} = \begin{bmatrix} a &-1 &\cdots &-1\\ -1 & a &\cdots &-1\\ \vdots &\vdots &\ddots &\vdots\\ -1 &-1 &\cdots & a \end{bmatrix},\qquad |a| < 1
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
num_winners ([type]) – number of winners.
self_excitation (float, optional) – self excitation factor. Defaults to 0.5.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Pool(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractPoolAdaptive Resonate & Fire Izhikevich input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Recurrent(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractRecurrentAdaptive Resonate & Fire Izhikevich recurrent block class. This should never be instantiated on its own. The recurrent formulation is described below:
s_\text{out}[t] = f_s\left(\mathbf{W}\,s_\text{in}[t] + \mathbf{R}\,s_{out}[t-1]\right)
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter.Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
requires_grad (bool, optional) – flag for learnable recurrent synapse. Defaults to True.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.TimeDecimation(*args, **kwargs)
Bases:
AbstractTimeDecimationAdaptive Resonate & Fire Izhikevich time decimation block class. This should never be instantiated on its own.
- Parameters:
factor (int, optional) – number of time units to decimate in a single bin. Must be in powers of 2.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.adrf_iz.Unpool(*args, **kwargs)
Bases:
AbstractADRFIZ,AbstractUnpoolAdaptive Resonate & Fire Izhikevich Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Adaptive RF-Izhikevich neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
Sigma Delta Block (SDN)
Sigma Delta layer blocks.
- class lava.lib.dl.slayer.block.sigma_delta.AbstractSDRelu(*args, **kwargs)
Bases:
ModuleAbstract Sigma Delta block class. This should never be instantiated on it’s own.
- class lava.lib.dl.slayer.block.sigma_delta.Average(*args, **kwargs)
Bases:
AbstractAverageSigma Delta average block class. This should never be instantiated on its own.
- Parameters:
num_outputs (int) – number of output population groups.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.Conv(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractConvSigma Delta convolution block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolution stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolution padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolution dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.ConvT(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractConvTSigma Delta convolution Traspose block class. This should never be instantiated on its own.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
in_features (int) – number of input features.
out_features (int) – number of output features.
kernel_size (int) – kernel size.
stride (int or tuple of two ints, optional) – convolutionT stride. Defaults to 1.
padding (int or tuple of two ints, optional) – convolutionT padding. Defaults to 0.
dilation (int or tuple of two ints, optional) – convolutionT dilation. Defaults to 1.
groups (int, optional) – number of blocked connections. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.Dense(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractDenseSigma Delta dense block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
mask (bool array, optional) – boolean synapse mask that only enables relevant synapses. None means no masking is applied. Defaults to None.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.Flatten(*args, **kwargs)
Bases:
AbstractFlattenSigma Delta flatten block class. This should never be instantiated on its own.
- Parameters:
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.Input(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractInputSigma Delta input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
weight (float, optional) – weight for affine transform of input. None means no weight scaling. Defaults to None.
bias (float, optional) – bias for affine transform of input. None means no bias shift. Defaults to None.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- forward(x)
- class lava.lib.dl.slayer.block.sigma_delta.Output(neuron_params, in_neurons, out_neurons, weight_scale=1, weight_norm=False, count_log=False)
Bases:
AbstractSDReluSigma Delta output block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict) – a dictionary of sigma delta neuron parameters.
in_neurons (int) – number of input neurons.
out_neurons (int) – number of output neurons.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- export_hdf5(handle)
Hdf5 export method for the block.
- Parameters:
handle (file handle) – hdf5 handle to export block description.
- forward(x)
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.sigma_delta.Pool(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractPoolSigma Delta input block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of pooling kernel.
stride (int or tuple of two ints, optional) – stride of pooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of pooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of pooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.
- class lava.lib.dl.slayer.block.sigma_delta.Unpool(*args, **kwargs)
Bases:
AbstractSDRelu,AbstractUnpoolSigma Delta Unpool block class. The block is 8 bit quantization ready.
- Parameters:
neuron_params (dict, optional) – a dictionary of Sigma Delta neuron parameter. Defaults to None.
kernel_size (int or tuple of two ints) – size of unpooling kernel.
stride (int or tuple of two ints, optional) – stride of unpooling operation. Defaults to None.
padding (int or tuple of two ints, optional) – padding of unpooling operation. Defaults to 0.
dilation (int or tuple of two ints, optional) – dilation of unpooling kernel. Defaults to 1.
weight_scale (int, optional) – weight initialization scaling. Defaults to 1.
weight_norm (bool, optional) – flag to enable weight normalization. Defaults to False.
pre_hook_fx (optional) – a function pointer or lambda that is applied to synaptic weights before synaptic operation. None means no transformation. Defaults to None.
delay (bool, optional) – flag to enable axonal delay. Defaults to False.
delay_shift (bool, optional) – flag to simulate spike propagation delay from one layer to next. Defaults to True.
count_log (bool, optional) – flag to return event count log. If True, an additional value of average event rate is returned. Defaults to False.