Utils

HDF5 net description manipulation utilities.

class lava.lib.dl.netx.utils.NetDict(filename=None, mode='r', f=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 is None. 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 and INHIBITORY : 2}.

lava.lib.dl.netx.utils.num_delay_bits(delays)

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)

Optimizes the weight matrix to best fit in Loihi’s synapse.

Parameters:

weight (np.ndarray) – standard 8 bit signed weight matrix.

Return type:

Tuple[ndarray, int, int, SYNAPSE_SIGN_MODE]

Returns:

  • np.ndarray – optimized weight matrix

  • int – weight bits

  • int – weight_exponent

  • SYNAPSE_SIGN_MODE – synapse sign mode