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

[Request] SuperSpike surrogate function #504

Closed JackCaster closed 4 months ago

JackCaster commented 4 months ago

Issue type

SpikingJelly version

0.0.0.0.14

Description I was wondering if you are thinking of implementing the SuperSpike surrogate function. It is the default one in Norse and the implementation is here

fangwei123456 commented 4 months ago

Hi, I just added this function (but not CUDA version). You can use it as:

import torch
from spikingjelly.activation_based import surrogate

x = torch.randn([8], requires_grad=True)
x[0].data.zero_()
sg = surrogate.SuperSpike()

print(x)
y = sg(x)
print(y)
y.sum().backward()
print(x.grad)