Utils
HDF5 net description manipulation utilities.
- class lava.lib.dl.netx.utils.NetDict(filename: Optional[str] = None, mode: str = 'r', f: Optional[Union[h5py._hl.files.File, h5py._hl.group.Group]] = None)
Provides dictionary like access to h5py object without the h5py quirks
- Parameters
filename (str or None, optional) – filename of h5py file to be loaded. It is only invoked if hdf5 file handle
f
isNone
. Default is None.mode (str, optional) – file open mode, by default ‘r’.
f (h5py.File or h5py.Group, optional) – hdf5 file object handle. Overwrites the function of filename if it is not
None
. Default is None.
- class lava.lib.dl.netx.utils.SYNAPSE_SIGN_MODE(value)
Enum for synapse sign mode. Options are {
MIXED : 1
,EXCITATORY : 2
andINHIBITORY : 2
}.
- lava.lib.dl.netx.utils.num_delay_bits(delays: numpy.ndarray) int
Calculates the number of delay bits required.
- Parameters
delays (np.ndarray) – delay vector
- Returns
number of delay bits.
- Return type
int
- lava.lib.dl.netx.utils.optimize_weight_bits(weight: numpy.ndarray) Tuple[numpy.ndarray, int, int, lava.lib.dl.netx.utils.SYNAPSE_SIGN_MODE]
Optimizes the weight matrix to best fit in Loihi’s synapse.
- Parameters
weight (np.ndarray) – standard 8 bit signed weight matrix.
- Returns
np.ndarray – optimized weight matrix
int – weight bits
int – weight_exponent
SYNAPSE_SIGN_MODE – synapse sign mode