jeshraghian / snntorch

Deep and online learning with spiking neural networks in Python
https://snntorch.readthedocs.io/en/latest/
MIT License
1.28k stars 217 forks source link

snntorch.surrogate.LSO returns StochasticSpikeOperator instead of LeakySpikeOperator #347

Open TommyClausner opened 2 weeks ago

TommyClausner commented 2 weeks ago

Description

I tried to use spike_grad = snntorch.surrogate.LSO(slope=0.1) with snntorch.Synaptic(alpha=alpha, beta=beta, spike_grad=spike_grad)

and got the error message:

TypeError: StochasticSpikeOperator.forward() missing 1 required positional argument: 'variance'

When checking the source I have seen that in snntorch.surrogate the following function might return the wrong value:

def LSO(slope=0.1):
    """Leaky spike operator gradient enclosed with a parameterized slope."""
    slope = slope

    def inner(x):
        return StochasticSpikeOperator.apply(x, slope)

    return inner

I think instead of returning StochasticSpikeOperator.apply(x, slope) it should return LeakySpikeOperator.apply(x, slope)