## 2 Background
### Spiking Neural Networks
A spike neuron model is considerably more complex than an artificial neuron model (accumulation and threshold), so its training and inference require higher computational effort than its simplified version. To train the LSNN model, we applied Backpropagation Through Time (BPTT) algorithm [19]. The network used in this work is described in [19]. The input layer is composed of input neurons (I) which are connected in an all-to-all fashion through the \(W^{I}\) matrix to the recurrent layer, which is composed of Adaptative-Integrate and Fire neuron (ALIF). The recurrent layer is connected recursively to itself with an all-to-all connection matrix \(W^{H}\), and it is linked to the output layer in an all-to-all fashion with the matrix \(W^{O}\). The ALIF neurons are described by two state variables \(v\) and \(a\). The first one is called membrane potential and increase when the neuron receives a stimulus (spike or current). When the \(v\) reach a value called \(v_{th}\), it emits a spike. The ALIF neurons have a changeable \(v_{th}\); this behaviour is described by \(a\) the second state variable. The following equations describe an ALIF neuron:  
\[v_{j}^{t}=\overbrace{e^{-\frac{a}{\tau_{th}}}}^{a}v_{j}^{t-1}+\sum_{i\
eq j}^ {\text{ALIF}\to\text{ALIF}}\overbrace{W_{ji}^{H}z_{i}^{t-1}}^{\text{In}\to \text{ALIF}}\overbrace{\sum W_{ji}^{H}x_{i}^{t}}^{\text{Reset}}-\overbrace{v _{th}z_{j}^{t-1}}^{\text{Reset}} \tag{1}\]  
\[a_{j}^{t}=e^{-\frac{a}{\tau_{th}}}a_{j}^{t-1}+z_{j}^{t-1} \tag{2}\]  
\[A_{j}^{t}=v_{th}+\rho a_{j}^{t}\]  
\[z_{j}^{t}= \begin{cases}1&\text{if }v_{j}^{t}\geq A_{j}^{t}\text{ and }r_{j}^{t}\
eq 1 \\ 0&\text{otherwise}\end{cases}  \tag{3}\]  
Equation (1) describes the update of the membrane potential. \(a\) is the decay of the neuron, and it depends on the tick (\(\delta t\)) of the network and the membrane time constant \(\tau_{m}\). The second and the third term describe the contribution of the recurrent part and the input layer, respectively. In the end, there is the reset of the membrane potential if this reaches the \(v_{th}\), \(z\) are the spikes of the ALIF, while \(x\) can be either spikes or current. Equation (2) describes the update of the spike threshold of the ALIF, \(\xi\) is the decay of the adaptative threshold, and it depends on \(\delta t\) and \(\tau_{a}\) called decay time constant, \(a\) is rescaled by a factor \(\rho\) before being added to \(v_{th}\). Equation (3) describe the spike condition. The neuron can spike (fire) only if it reaches a certain value (\(A\)) and if it is not in the refractory period (\(r\)). The refractory period is triggered when a neuron spike, and it is a time-lapse in which the neuron cannot fire. The output neurons are continuous; therefore, the output is not a spike train but a continuous waveform. The following equation describes the outputs neurons:  
\[y_{k}^{t}=\overbrace{e^{-\frac{\rho}{\tau_{0}}}}^{\beta}y_{k}^{t-1}+\overbrace {\sum W_{kj}^{O}z_{j}^{t}}^{\text{AllIF}\to\text{Out}}_{k} \tag{4}\]  
where \(\tau_{0}\) is the decay constant of the membrane potential of the neurons and \(b\) is the bias of the neuron, which represents a constant current that stimulates the neuron.