lava-nc / lava

A Software Framework for Neuromorphic Computing
https://lava-nc.org
Other
555 stars 143 forks source link

Conv ProcessModels Ignore weight_exp Parameter #803

Open Gavinator98 opened 11 months ago

Gavinator98 commented 11 months ago

Describe the bug The conv process specifies a weight_exp parameter to scale the weights by a power of 2, similar to the dense process. The NcProcessModel (and seemingly all of the other Conv process models) do not utilize this weight_exp.

To reproduce current behavior

Specify a weight_exp

Conv(weight=np.ones((3, 1, 1, 3)), weight_exp=4)

Expected behavior Weights are scaled by weight_exp when applied.

Environment (please complete the following information):

Gavinator98 commented 11 months ago

One alternative to having a weight_exp parameter in the Process could be to have the optimize_weight_bits take in floating point inputs and let it compute the weight_exp automatically. This line: https://github.com/lava-nc/lava/blob/f7796e7571204b89f59ab4b61774942a736fbc99/src/lava/utils/weightutils.py#L80 would need to be changed to something like:

weights = np.round(weights * 2**(-weight_exp)).astype(np.int32)

to prevent the weights from being unnecessarily truncated.