synsense / sinabs

A deep learning library for spiking neural networks which is based on PyTorch, focuses on fast training and supports inference on neuromorphic hardware.
https://sinabs.readthedocs.io
GNU Affero General Public License v3.0
77 stars 8 forks source link

LIF and IAF classes can output values below min_v_mem when not spiking #236

Open bauerfe opened 4 months ago

bauerfe commented 4 months ago

It is possible to instantiate the LIF and IAF classes without a spike function. In that case the membrane potentials v_mem will be used as the layer output.

When a value for min_v_mem is provided, v_mem is clipped at this value. However, currently the clipping happens after v_mem is copied to the output tensor, hence the output can be less than the defined lower limit min_v_mem.

The fix should be easy: Move this if-else-block before the spike generation block just above it.

For the ALIF layer this might also be an issue.