Lava Utils
lava.utils.float2fixed
lava.utils.profiler
digraph inheritanceb09c61de0b { bgcolor=transparent; rankdir=TB; size=""; "Profiler" [URL="../lava/lava.utils.html#lava.utils.profiler.Profiler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for profiling execution time, energy and other"]; }- class lava.utils.profiler.Profiler
Bases:
object
Base class for profiling execution time, energy and other metrics on different resources. Depending on the computing ressource an appropriate profiler needs to be chosen. The run configuration is used to choose the related profiler, if there is one.
lava.utils.system
digraph inheritance2584afbd65 { bgcolor=transparent; rankdir=TB; size=""; "Loihi2" [URL="../lava/lava.utils.html#lava.utils.system.Loihi2",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "staticproperty" [URL="../lava/lava.utils.html#lava.utils.system.staticproperty",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Wraps static member function of a class as a static property of that"]; }- class lava.utils.system.Loihi2
Bases:
object
- is_loihi2_available = False
- partition = 'Unspecified'
-
preferred_partition:
str
= None
- static set_environ_settings(partititon=None)
Sets the os environment for execution on Loihi. :type partititon:
Optional
[str
] :param partititon: Loihi partition name, by default None. :type partititon: str, optional- Return type:
None
- lava.utils.system.deprecated(__msg)
- Return type:
Callable
[[TypeVar
(_T
)],TypeVar
(_T
)]
- class lava.utils.system.staticproperty(fget=None, fset=None, fdel=None, doc=None)
Bases:
property
Wraps static member function of a class as a static property of that class.
lava.utils.validator
lava.utils.visualizer
lava.utils.weightutils
digraph inheritance79ee4e0b76 { bgcolor=transparent; rankdir=TB; size=""; "Enum" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Generic enumeration."]; "OptimizedWeights" [URL="../lava/lava.utils.html#lava.utils.weightutils.OptimizedWeights",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="OptimizedWeights(weights: Union[numpy.ndarray, scipy.sparse._matrix.spmatrix], num_weight_bits: int, weight_exp: int)"]; "SignMode" [URL="../lava/lava.utils.html#lava.utils.weightutils.SignMode",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Enumeration of sign mode of weights."]; "Enum" -> "SignMode" [arrowsize=0.5,style="setlinewidth(0.5)"]; }- class lava.utils.weightutils.OptimizedWeights(weights, num_weight_bits, weight_exp)
Bases:
object
-
num_weight_bits:
int
-
weight_exp:
int
-
weights:
Union
[ndarray
,spmatrix
]
-
num_weight_bits:
- class lava.utils.weightutils.SignMode(value)
Bases:
Enum
Enumeration of sign mode of weights.
- EXCITATORY = 2
- INHIBITORY = 3
- MIXED = 1
- NULL = 0
- lava.utils.weightutils.clip_weights(weights, sign_mode, num_bits, learning_simulation=False)
Truncate the least significant bits of the weight matrix given the sign mode and number of weight bits.
- Parameters:
weights (numpy.ndarray, spmatrix) – Weight matrix that is to be truncated.
sign_mode (SignMode) – Sign mode to use for truncation.
num_bits (int) – Number of bits to use to clip the weights to.
learning_simulation (bool, optional) – Boolean flag, specifying if this method is used in context of learning (in simulation).
- Returns:
Truncated weight matrix.
- Return type:
numpy.ndarray
- lava.utils.weightutils.determine_sign_mode(weights)
Determines the sign mode that describes the values in the given weight matrix.
- Parameters:
weights (numpy.ndarray) – Weight matrix
- Returns:
The sign mode that best describes the values in the given weight matrix.
- Return type:
- lava.utils.weightutils.optimize_weight_bits(weights, sign_mode, loihi2=False)
Optimizes the weight matrix to best fit in Loihi’s synapse.
- Parameters:
weights (np.ndarray, spmatrix) – Standard 8-bit signed weight matrix.
sign_mode (SignMode) – Determines whether the weights are purely excitatory, inhibitory, or mixed sign.
loihi2 (bool, optional) – Flag to optimize for Loihi 2. By default False.
- Returns:
An object that wraps the optimized weight matrix and weight parameters.
- Return type:
- lava.utils.weightutils.truncate_weights(weights, sign_mode, num_weight_bits, max_num_weight_bits=8)
Truncate the least significant bits of the weight matrix given the sign mode and number of weight bits.
- Parameters:
weights (numpy.ndarray, spmatrix) – Weight matrix that is to be truncated.
sign_mode (SignMode) – Sign mode to use for truncation. See SignMode class for the correct values.
num_weight_bits (int) – Number of bits to use for the weight matrix.
max_num_weight_bits (int, optional) – Maximum number of bits that can be used to represent weights. Default is 8.
- Returns:
Truncated weight matrix.
- Return type:
numpy.ndarray