fangwei123456 / spikingjelly

SpikingJelly is an open-source deep learning framework for Spiking Neural Network (SNN) based on PyTorch.
https://spikingjelly.readthedocs.io
Other
1.24k stars 235 forks source link

changing the surrogate function and type of spiking neuron for spiking neurons which are available in the converter snn model #484

Open gwgknudayanga opened 6 months ago

gwgknudayanga commented 6 months ago

Hi,

after i did the conversion from ann to snn the converted snn model is look like this. However i cannot see the snn tailor part with snn_model.named_parameters() method. Actually i want to know,

  1. how to change the type of neuron to LIF/ALIF instead of default IF?
  2. how to the surrgoate function to relu instead of sigmoid for the spiking neurons in a given layer?
  3. how can i use my own surrogate function for the spiking neurons in the output layer so that i can disable the spiking behavior of those neurons and sum up the voltages ?
    bbb
Lyu6PosHao commented 6 months ago

Hello, if you want to see "snn tailor" parts, you can refer to _snn_model.namedmodules().

To your three questions:

  1. You can rewrite the source code of converter.py in SpikingJelly. Just change the 314-th line of converter.py: m1 = neuron.IFNode(v_threshold=1., v_reset=None) Change this IFNode to LIF/ALIF. In addition, if you want to change IFNode in a snn_model that finished converting, you can change the related modules in _snn_model.namedmodules().

  2. Maybe you should rewrite the source code of IFNode in neuron.py. Or you can design your own spiking neuron. It is not very difficult.

  3. As discussed above, you may design your own spiking neuron.

Hope it is helpful.