NeuromorphicProcessorProject / snn_toolbox

Toolbox for converting analog to spiking neural networks (ANN to SNN), and running them in a spiking neuron simulator.
MIT License
360 stars 104 forks source link

Poisson Rate Encoding #141

Closed abdul-muneeb7 closed 7 months ago

abdul-muneeb7 commented 10 months ago

Hi @rbodo I have a question regarding Poisson encoding. My custom Spiking CNN network is working with the first layer computing convolutions in floating-point MAC operations but I want to feed my input as a spike train for that I have turned ON the flag for "poisson_input" in the config file.

My input data is normalized between (0,1), but the spike train generated by the Poisson encoder is [0, 0, 0, 0.74447775, 0, 0.74447775, 0], etc. I mean instead of generating [0, 0, 0, 1, 0, 1, 0]. why it is generating 0.74447775 not 1 at the spike generation. To resolve this issue, I looked into how the Poisson rate encoder is working in SNNtoolbox, and couldn't find any documentation related to that methodology. Kindly can you guide me in this regard.

rbodo commented 9 months ago

Hi @abdul-muneeb7 , sorry for the delayed response.

The poisson encoding happens here. The line that probably causes the non-binary spikes you observed is here. This step assumes that the input samples contained in x_b_l are normalized, such that max(x_b_l) == 1, in which case this line does not modify the spikes. It is possible however that even after normalizing the dataset globally (which you did), an individual batch x_b_l may not have a maximum of 1. Another possibility is that you did not use max norm but some percentile norm so that the global maximum is different from 1. I'd recommend removing line 302 as it was only intended for the special case of networks with binary weights.

abdul-muneeb7 commented 9 months ago

Sure, Thanks for getting back to me @rbodo. I have seen this poisson encoding code part, here but just wanted to learn more from the explanation in any of your papers.

rbodo commented 9 months ago

The basic idea is that at each time step you draw a random number and if it is below the poisson rate parameter, you get a spike. The higher the rate parameter, the higher the probability of generating a spike.

abdul-muneeb7 commented 9 months ago

Got it. Thanks, Prof. @rbodo.