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:
Module
Abstract 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
NCT
orNCHWT
format.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractAverage(num_outputs, count_log=False)
Bases:
Module
Abstract 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
NCT
orNCHWT
format.
- 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:
Module
Abstract 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
NCHWT
format.
- 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:
Module
Abstract 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:
Module
Abstract 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
NCT
orNCHWT
format.
- property shape
Shape of the block.
- class lava.lib.dl.slayer.block.base.AbstractFlatten(count_log=False)
Bases:
Module
Abstract 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
NCT
orNCHWT
format.
- class lava.lib.dl.slayer.block.base.AbstractInput(neuron_params=None, weight=None, bias=None, delay_shift=True, count_log=False)
Bases:
Module
Abstract 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
NCT
orNCHWT
format.
- 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:
Module
Abstract 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
NCT
orNCHWT
format.
- 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:
Module
Abstract 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
NCHWT
format.
- 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:
Module
Abstract 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
NCT
orNCHWT
format.
- 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:
Module
Abstract 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
NCT
orNCHWT
format.
- 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:
Module
Abstract 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:
Module
Abstract 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
,AbstractAffine
CUBA 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:
AbstractAverage
CUBA 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
,AbstractConv
CUBA 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
,AbstractConvT
CUBA 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
,AbstractDense
CUBA 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:
AbstractFlatten
CUBA 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
,AbstractInput
CUBA 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
,AbstractKWTA
CUBA 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
,AbstractPool
CUBA 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
,AbstractRecurrent
CUBA 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:
AbstractTimeDecimation
CUBA 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
,AbstractUnpool
CUBA 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:
Module
Abstract 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
,AbstractAffine
Resonate & 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:
AbstractAverage
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.rf.Conv(*args, **kwargs)
Bases:
AbstractRF
,AbstractConv
Resonate & 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
,AbstractConvT
Resonate & 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
,AbstractDense
Resonate & 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:
AbstractFlatten
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.rf.Input(*args, **kwargs)
Bases:
AbstractRF
,AbstractInput
Resonate & 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
,AbstractKWTA
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 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
,AbstractPool
Resonate & 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
,AbstractRecurrent
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 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:
AbstractTimeDecimation
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.rf.Unpool(*args, **kwargs)
Bases:
AbstractRF
,AbstractUnpool
Resonate & 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:
Module
Abstract 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
,AbstractAffine
Resonate & 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:
AbstractAverage
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.rf_iz.Conv(*args, **kwargs)
Bases:
AbstractRFIz
,AbstractConv
Resonate & 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
,AbstractConvT
Resonate & 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
,AbstractDense
Resonate & 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:
AbstractFlatten
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.rf_iz.Input(*args, **kwargs)
Bases:
AbstractRFIz
,AbstractInput
Resonate & 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
,AbstractKWTA
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 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
,AbstractPool
Resonate & 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
,AbstractRecurrent
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 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:
AbstractTimeDecimation
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.rf_iz.Unpool(*args, **kwargs)
Bases:
AbstractRFIz
,AbstractUnpool
Resonate & 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:
Module
Abstract 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:
AbstractAverage
Adaptive 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
,AbstractConv
Adaptive 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
,AbstractConvT
Adaptive 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
,AbstractDense
Adaptive 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:
AbstractFlatten
Adaptive 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
,AbstractInput
Adaptive 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
,AbstractKWTA
Adaptive 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
,AbstractPool
Adaptive 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
,AbstractRecurrent
Adaptive 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:
AbstractTimeDecimation
Adaptive 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
,AbstractUnpool
Adaptive 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:
Module
Abstract Adaptive Resonate and Fire block. This should never be instantiated on its own.
- class lava.lib.dl.slayer.block.adrf.Average(*args, **kwargs)
Bases:
AbstractAverage
Adaptive 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
,AbstractConv
Adaptive 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
,AbstractConvT
Adaptive 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
,AbstractDense
Adaptive 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:
AbstractFlatten
Adaptive 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
,AbstractInput
Adaptive 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
,AbstractKWTA
Adaptive 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
,AbstractPool
Adaptive 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
,AbstractRecurrent
Adaptive 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:
AbstractTimeDecimation
Adaptive 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
,AbstractUnpool
Adaptive 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:
Module
Abstract 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:
AbstractAverage
Adaptive 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
,AbstractConv
Adaptive 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
,AbstractConvT
Adaptive 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
,AbstractDense
Adaptive 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:
AbstractFlatten
Adaptive 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
,AbstractInput
Adaptive 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
,AbstractKWTA
Adaptive 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
,AbstractPool
Adaptive 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
,AbstractRecurrent
Adaptive 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:
AbstractTimeDecimation
Adaptive 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
,AbstractUnpool
Adaptive 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:
Module
Abstract 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:
AbstractAverage
Sigma 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
,AbstractConv
Sigma 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
,AbstractConvT
Sigma 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
,AbstractDense
Sigma 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:
AbstractFlatten
Sigma 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
,AbstractInput
Sigma 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:
AbstractSDRelu
Sigma 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
,AbstractPool
Sigma 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
,AbstractUnpool
Sigma 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.