lava.proc.dense

lava.proc.dense.models

Inheritance diagram of lava.proc.dense.models
class lava.proc.dense.models.AbstractPyDenseModelBitAcc(proc_params)

Bases: PyLoihiProcessModel

Implementation of Conn Process with Dense synaptic connections that is bit-accurate with Loihi’s hardware implementation of Dense, which means, it mimics Loihi behavior bit-by-bit.

a_buff: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'numpy.int32'>, precision=16)
a_out: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'numpy.int32'>, precision=16)
num_message_bits: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=5)
run_spk()

Function that runs in Spiking Phase

s_in: PyInPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyInPortVectorDense'>, d_type=<class 'bool'>, precision=1)
weights: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'numpy.int32'>, precision=8)
class lava.proc.dense.models.AbstractPyDenseModelFloat(proc_params=None)

Bases: PyLoihiProcessModel

Implementation of Conn Process with Dense synaptic connections in floating point precision. This short and simple ProcessModel can be used for quick algorithmic prototyping, without engaging with the nuances of a fixed point implementation.

a_buff: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=None)
a_out: PyOutPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyOutPortVectorDense'>, d_type=<class 'float'>, precision=None)
num_message_bits: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'int'>, precision=5)
run_spk()

Function that runs in Spiking Phase

s_in: PyInPort = LavaPyType(cls=<class 'lava.magma.core.model.py.ports.PyInPortVectorDense'>, d_type=<class 'bool'>, precision=1)
weights: ndarray = LavaPyType(cls=<class 'numpy.ndarray'>, d_type=<class 'float'>, precision=None)
class lava.proc.dense.models.PyDenseModelBitAcc(proc_params)

Bases: AbstractPyDenseModelBitAcc

implements_process

alias of Dense

implements_protocol

alias of LoihiProtocol

model_id: ty.Optional[int]
proc_params: ty.Type['ProcessParameters']
process_to_service: ty.Optional[CspSendPort]
py_ports: ty.List[AbstractPyPort]
required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
service_to_process: ty.Optional[CspRecvPort]
tags: ty.List[str] = ['bit_accurate_loihi', 'fixed_pt']
var_id_to_var_map: ty.Dict[int, ty.Any]
var_ports: ty.List[PyVarPort]
class lava.proc.dense.models.PyDenseModelFloat(proc_params=None)

Bases: AbstractPyDenseModelFloat

implements_process

alias of Dense

implements_protocol

alias of LoihiProtocol

model_id: ty.Optional[int]
proc_params: ty.Type['ProcessParameters']
process_to_service: ty.Optional[CspSendPort]
py_ports: ty.List[AbstractPyPort]
required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
service_to_process: ty.Optional[CspRecvPort]
tags: ty.List[str] = ['floating_pt']
var_id_to_var_map: ty.Dict[int, ty.Any]
var_ports: ty.List[PyVarPort]
class lava.proc.dense.models.PyLearningDenseModelBitApproximate(proc_params)

Bases: LearningConnectionModelBitApproximate, AbstractPyDenseModelBitAcc

Implementation of Conn Process with Dense synaptic connections that is bit-accurate with Loihi’s hardware implementation of Dense, which means, it mimics Loihi behaviour bit-by-bit.

implements_process

alias of LearningDense

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
run_spk()

Function that runs in Spiking Phase

tags: ty.List[str] = ['bit_approximate_loihi', 'fixed_pt']
class lava.proc.dense.models.PyLearningDenseModelFloat(proc_params)

Bases: LearningConnectionModelFloat, AbstractPyDenseModelFloat

Implementation of Conn Process with Dense synaptic connections in floating point precision. This short and simple ProcessModel can be used for quick algorithmic prototyping, without engaging with the nuances of a fixed point implementation.

implements_process

alias of LearningDense

implements_protocol

alias of LoihiProtocol

required_resources: ty.List[ty.Type[AbstractResource]] = [<class 'lava.magma.core.resources.CPU'>]
run_spk()

Function that runs in Spiking Phase

tags: ty.List[str] = ['floating_pt']

lava.proc.dense.process

Inheritance diagram of lava.proc.dense.process
class lava.proc.dense.process.Dense(*, weights, name=None, num_message_bits=0, log_config=None, **kwargs)

Bases: AbstractProcess

Dense connections between neurons. Realizes the following abstract behavior: a_out = weights * s_in

Parameters
  • weights (numpy.ndarray) – 2D connection weight matrix of form (num_flat_output_neurons, num_flat_input_neurons) in C-order (row major).

  • weight_exp (int, optional) – Shared weight exponent of base 2 used to scale magnitude of weights, if needed. Mostly for fixed point implementations. Unnecessary for floating point implementations. Default value is 0.

  • num_weight_bits (int, optional) – Shared weight width/precision used by weight. Mostly for fixed point implementations. Unnecessary for floating point implementations. Default is for weights to use full 8 bit precision.

  • sign_mode (SignMode, optional) –

    Shared indicator whether synapse is of type SignMode.NULL, SignMode.MIXED, SignMode.EXCITATORY, or SignMode.INHIBITORY. If SignMode.MIXED, the sign of the weight is included in the weight bits and the fixed point weight used for inference is scaled by 2. Unnecessary for floating point implementations.

    In the fixed point implementation, weights are scaled according to the following equations: w_scale = 8 - num_weight_bits + weight_exp + isMixed() weights = weights * (2 ** w_scale)

  • num_message_bits (int, optional) – Determines whether the Dense Process deals with the incoming spikes as binary spikes (num_message_bits = 0) or as graded spikes (num_message_bits > 0). Default is 0.

class lava.proc.dense.process.LearningDense(*, weights, name=None, num_message_bits=0, log_config=None, learning_rule=None, **kwargs)

Bases: LearningConnectionProcess, Dense

Dense connections between neurons. Realizes the following abstract behavior: a_out = weights * s_in ‘

Parameters
  • weights (numpy.ndarray) – 2D connection weight matrix of form (num_flat_output_neurons, num_flat_input_neurons) in C-order (row major).

  • weight_exp (int, optional) – Shared weight exponent of base 2 used to scale magnitude of weights, if needed. Mostly for fixed point implementations. Unnecessary for floating point implementations. Default value is 0.

  • num_weight_bits (int, optional) – Shared weight width/precision used by weight. Mostly for fixed point implementations. Unnecessary for floating point implementations. Default is for weights to use full 8 bit precision.

  • sign_mode (SignMode, optional) –

    Shared indicator whether synapse is of type SignMode.NULL, SignMode.MIXED, SignMode.EXCITATORY, or SignMode.INHIBITORY. If SignMode.MIXED, the sign of the weight is included in the weight bits and the fixed point weight used for inference is scaled by 2. Unnecessary for floating point implementations.

    In the fixed point implementation, weights are scaled according to the following equations: w_scale = 8 - num_weight_bits + weight_exp + isMixed() weights = weights * (2 ** w_scale)

  • num_message_bits (int, optional) – Determines whether the LearningDense Process deals with the incoming spikes as binary spikes (num_message_bits = 0) or as graded spikes (num_message_bits > 0). Default is 0.

  • learning_rule (LoihiLearningRule) – Learning rule which determines the parameters for online learning.