jeshraghian / snntorch

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

synaptic.py has sth wrong #349

Open YOUNGLBIN opened 1 month ago

YOUNGLBIN commented 1 month ago

Description

When I use snn.Synaptic, something unexpected happened. So I check the synaptic.py, i found the 219line "self.syn = mem" should be replaced with "self.syn = syn". I done this in my local computer, Things have become normal now

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
Roiwa commented 1 month ago

Agreed! I have the same issue while making tutorial 4.

Nevertheless, I think the correct way to use Synaptic is to instantiate the neuron: lif1 = snn.Synaptic(alpha=alpha, beta=beta) Then initialize the neuron: syn, mem = lif1.init_synaptic(). In fact, nowadays, we have to use syn, mem = lif1.reset_mem() and while calling the neuron we need to use: spk_out, syn, mem = lif1(spk_in[step]), instead of spk_out, syn, mem = lif1(spk_in[step],syn,mem), as it uses syn and mem attributes (self.syn and self.mem)