S PIKE - INSPIRED R ANK C ODING FOR F AST AND A CCURATE R ECURRENT N EURAL N ETWORKS
Anonymous authors
Paper under double-blind review
A BSTRACT
Biological spiking neural networks (SNNs) can temporally encode information in their outputs, e.g. in the rank order in which neurons ﬁre, whereas artiﬁcial neural networks (ANNs) conventionally do not.
As a result, models of SNNs for neuromorphic computing are regarded as potentially more rapid and efﬁcient than ANNs when dealing with temporal input.
On the other hand, ANNs are simpler to train, and usually achieve superior performance.
Here we show that temporal coding such as rank coding (RC) inspired by SNNs can also be applied to conventional ANNs such as LSTMs, and leads to computational savings and speedups.
In our RC for ANNs, we apply backpropagation through time using the standard real-valued activations, but only from a strategically early time step of each sequential input example, decided by a threshold-crossing event.
Learning then incorporates naturally also when to produce an output, without other changes to the model or the algorithm.
Both the forward and the backward training pass can be signiﬁcantly shortened by skipping the remaining input sequence after that ﬁrst event.
RC-training also signiﬁcantly reduces time-to-insight during inference, with a minimal decrease in accuracy.
The desired speed-accuracy trade-off is tunable by varying the threshold or a regularization parameter that rewards output entropy.
We demonstrate these in two toy problems of sequence classiﬁcation, and in a temporally-encoded MNIST dataset where our RC model achieves 99.19% accuracy after the ﬁrst input time-step, outperforming the state of the art in temporal coding with SNNs, as well as in spoken-word classiﬁcation of Google
Speech Commands, outperforming non-RC-trained early inference with LSTMs.
I NTRODUCTION
Neuromorphic computing is the study and use of computational mechanisms of biological neural networks in mathematical models, software simulations, and hardware emulations, both as a tool for neuroscience, and as a possible path towards improved machine intelligence (Indiveri, 2021).
In fact, much of the recent progress in machine learning (ML) can be attributed to artiﬁcial neural networks (ANNs), which share certain characteristics with biological neural networks.
These biological analogies of ANN models include a connectionist graph-like structure (Rosenblatt, 1958), parallel computing over multiple synaptic weights and neurons (Indiveri & Horiuchi, 2011), and the non-von Neumann collocation of memory and processing at each synapse and neuron (Sebastian et al., 2020).
On the other hand, state-of-the-art (SOTA) ANNs for ML often miss several other neuromorphic mechanisms that are fundamental in biological neural systems.
A characteristic example is that of “spikes”, i.e. the short stereotypical pulses that biological neurons emit to communicate (Maass, 1997; Ponulak & Kasinski, 2011).
This is a principal neuromorphic feature, characterizing the brain and a broad category of bio-plausible models of computation known as spiking neural networks (SNNs), but not the most successful ANNs, suggesting unexploited potential and limited understanding of spike-based approaches.
Despite the stereotypical, unmodulated shape of spikes, spiking neurons can encode continuous values, for example in their average ﬁring rate (Brette, 2015), which is abstracted into the continuous activation of conventional artiﬁcial neurons (Pfeiffer & Pfeil, 2018).
Perhaps more interestingly, spikes can also carry information in their speciﬁc timing, i.e. through temporal coding that modulates when spikes are ﬁred (Brette, 2015).
Partly because individual spikes can encode information sparsely and rapidly, biological nervous systems and spiking neuromorphic systems can be extremely energy-efﬁcient and fast in the processing of their input stimuli (Qiao et al., 2015; Davies et al., 2018;
Zhou et al., 2021;
Yin et al., 2021).
This efﬁciency and speed are key motivations for much of the research on SNNs for potential applications in ML and inference.
Moreover, owing to neuronal and synaptic dynamics, SNNs are more powerful computational models than certain ANNs in theory (Maass, 1997; Moraitis et al., 2020).
In practice, SNNs have recently surpassed conventional ANNs in accuracy in particular ML tasks, by virtue of short-term synaptic plasticity (Leng et al., 2018; Moraitis et al., 2020).
Spike coding itself can also add computational power to SNNs by increasing the dimensionality of neuronal responses (Izhikevich, 2006; Moraitis et al., 2018).
However, in practical ML terms, ﬁrstly, spike coding poses difﬁculties to precise modelling and training that require ad hoc mitigation techniques (Mostafa, 2017; Pauli et al., 2018; Pfeiffer & Pfeil, 2018; Coms¸a et al., 2021; Zhang et al., 2021).
Secondly,
SNNs are particularly difﬁcult to analyse mathematically and rigorous ML-theoretic spiking models are scarce (Nessler et al., 2013; Moraitis et al., 2020).
Thirdly, they require unconventional neuronal models, which do not fully beneﬁt from the mature theoretical and practical toolbox of conventional
ANNs (Bellec et al., 2018; Wo´zniak et al., 2020; Coms¸a et al., 2021).
As a result, the efﬁciency and speed beneﬁts of temporal coding for ML have been hard to demonstrate with SOTA accuracy in real-world tasks.
For instance, very recent literature on temporal coding with SNNs (Coms¸a et al., 2021; Zhang et al., 2021;
Zhou et al., 2021; Mirsadeghi et al., 2021; G¨oltz et al., 2021) uses rank coding (RC), i.e. the temporal scheme where the ﬁrst output neuron to spike encodes the network’s inferred label (Thorpe & Gautrais, 1998), and it applies it to speed up inference on tasks such as hand-written digit (MNIST)
(Lecun et al., 1998) recognition.
However, when applied (Zhou et al., 2021) to more difﬁcult datasets such as Imagenet (Deng et al., 2009), the accuracy is signiﬁcantly lower than in non-spiking versions of the same network (Szegedy et al., 2015).
Moreover, in these demonstrations there are no directly measured beneﬁts compared to non-spiking ANNs.
Even though temporal coding is usually not described in terms comparable with non-spiking ANNs, there are in fact ANN architectures with certain analogies to RC, when viewed from a particular angle.
Namely, in an SNN that receives a sequence example of several input steps, e.g. in a sequenceclassiﬁcation task, one implication of RC is that the computation for each sequence example can be halted after the ﬁrst output neuron has spiked and produced an inferred label, even if several steps of the input sequence still remain unseen.
Therefore, this is an adaptive type of processing that dynamically chooses the time and computation to be dedicated to each sequence.
From this perspective,
RC is related to ANN techniques such as Self-Delimiting Neural Networks (Schmidhuber, 2012),
Adaptive Computation Time (Graves, 2016), and PonderNet (Banino et al., 2021), which are also concerned with when computation should halt.
However, these methods do not aim to adaptively reduce the processed length of an input sequence as RC does, but rather to adaptively add timesteps of processing to each step of the input sequence.
A possibly more deeply related method is that of adaptive early-exit inference (Laskaridis et al., 2021).
In this case, the forward propagation of an input throughout layers in a deep neural network at inference time is forwarded from an early layer directly to a classiﬁer head, skipping the layers that remain higher in the hierarchy, if that early layer crosses a conﬁdence threshold.
In certain cases, early exit has been applied to sequence classiﬁcation with recurrent neural networks (RNNs), where the threshold-crossing dictates when in the sequence of an input example the network should output its inference, saving indeed in terms of time and computation (Dennis et al., 2018; Tan et al., 2021).
This timing decision based on the ﬁrst cross of a threshold is similar to inference with RC.
However, these early-exit models were not speciﬁcally trained to learn a rank code.
It is conceivable that this mismatch between training and inference is suboptimal.
In addition, this non-RC training of early-exit inference models does not apply the computational savings and speed beneﬁts also to the training process.
Taking together the limitations and beneﬁts of SNNs and of other approaches, what is needed is a strategy that introduces aspects of RC into conventional, non-spiking ANNs, including during training.
This would potentially reap the speed and efﬁciency beneﬁts of this neuromorphic scheme, without abandoning the real-world usability and performance of ANNs.
In addition, these insights into neural coding could feed back to neuroscience.
Here we describe and demonstrate such a strategy for temporal coding in deep learning and inference with ANNs.
The general concept is simple.
Namely, even though ANN activations are continuous-valued and therefore neurons do not have to rely on time to encode information as in SNNs, ANNs too could time their outputs and, importantly, they could learn to do so.
To achieve this in an RNN such as long short-term memory (LSTM) (Hochreiter & Schmidhuber, 1997), we back-propagate through time (BPTT) from a strategic and early time step in each training example’s sequence.
The time step is decided by the rank-one, i.e. ﬁrst, output neuron activation to cross a threshold.
As a result of this Rank Coding (RC) during training, the network learns not only to minimize the loss function, but implicitly also to optimize the timing of its outputs, reducing time to insight as well as computational demands of training and inference.
In our experiments, we provide several demonstrations, with advantages compared to
SNNs from the literature as well as compared to conventional ANN techniques, including in MNIST classiﬁcation and speech recognition.
D EEP L EARNING OF R ANK C ODING
Algorithm
Given: a training set of N example sequences S i = { x i 0 , ..., x iT } and corresponding labels y i ; an
RNN R ; and a threshold θ .
1: i =2: while i < N do (cid:46) iterate over training examples 3: i + + ; t = 0 ;
T i = duration of sequence S i 4: t sp,i ← T i (cid:46) latest possible ﬁrst “spike” 5: while t < t sp,i do (cid:46) iterate through input sequence steps until ﬁrst spike 6: t + + 7: activation ˆ y it =
R t ( S i ) 8: for all output neurons
ˆ y j do 9: if ˆ y jit ≥ θ then (cid:46) Inferred label= j 10: t sp,i ← t (cid:46) rank-one spike time 11: ˆ y i
= ˆ y it (cid:46) activation at t sp is considered as R ’s overall output from S i 12:
BPTT( R , Loss( ˆ y it , y i ))
(cid:46) BPTT from t sp only 13: break (cid:46)
Done with this sequence
Algorithm 1 shows the RC-training process.
The network decides the rank-one spike timing t sp of its outputs based on its output-layer activations and a threshold θ (line 10).
The loss function can be a common loss function such as cross-entropy.
There is no explicit parametrization on time, and only one instantaneous output ˆ y it is used in the loss (line 12).
Therefore, RC-training does not explicitly optimize the timing t sp of the network’s outputs.
Thus, it is not obvious that learning of the timing aspect can emerge from this algorithm.
Nevertheless, timing is implicitly, albeit indeed optimized.
This does become more evident if we focus on the effects that training implies on timing t sp .
With random initialization, initially, the activations are nearly uniformly distributed across output neurons, and are smaller than the threshold, throughout the sequence.
Without an earlier cross of a threshold, the algorithm applies BPTT from the last step of the sequence (line 4: t sp = T ).
As training advances, minimizing the error between the outputs and the labels minimizes the entropy of the output distribution, i.e. causes the output activations at the end of each sequence example to be concentrated around one of the output neurons, such that the maximum activation ˆ y maxt sp is maximized.
Through BPTT from that last time step, credit is assigned to earlier time steps as well.
Progressively through training, this causes outputs to cross the threshold earlier and earlier, under the condition that relevant, credit-assigned input signal does exist earlier.
This conditional acceleration causes the optimization of output timing.
This is also shown mathematically below, after the deﬁnitions and prerequisites 1-3:
[Equation]
j := class of the input
[Equation]
Moreover, min Loss ( ˆ y t sp , y ) =
⇒ min
Entropy ( ˆ y t sp ) =
⇒ max ˆ y
[Equation]
sp
[Equation]
(cid:2) RC-training (cid:12) (cid:12) given that signal that is partly responsible for label j is present in the input before t sp (cid:3) =
⇒ (cid:20) min Loss ( ˆ y t sp , y ) (cid:12)(cid:12)(cid:12)(cid:12) ∂P
[Equation]
[Equation]
Importantly, the insight that it is through the minimization of entropy (Eq. 3 & 5) that timing is minimized, gives us access to a mechanism for balancing between minimizing the loss and minimizing the timing.
Speciﬁcally, we introduce to the loss function a regularization term, weighted by a hyperparameter β , such that minimization of the loss rewards entropy H of the outputs ˆ y t sp :
[Equation]
RC-inference after RC-training is similar to Algorithm 1 but the backward pass (line 12) is not applied.
It should be noted that the inference stage on its own performed in this manner, where a threshold decides the timing of the output, is a version of what has been called early exit or early inference.
In our implementation, the expectation is that the model learns to encode information in the rank order of its output’s timing, because that timing is integrated into the learning process.
In this sense, at inference, the model does not merely exit early, but it does so through an underlying learned rank code (RC).
Our experimental demonstrations conﬁrmed that the loss is minimized through RC-training, although BPTT’s application time-step varies between training examples, and that the timing is also minimized, down to an optimal ﬂoor condition, as predicted by the theoretical conditional result of Eq. 6.
E XPERIMENTAL DEMONSTRATIONS 3. C ONTINUOUS SEQUENCE SPOTTING
The ﬁrst task where we tested RC involves Poisson spike trains of a constant average ﬁring rate of 0.5 spikes per time-step.
Each Poisson input sequence consists of 25 binary time-steps (Fig.
1A).
The task is to conclude as soon as possible within each sequence whether the sequence includes a period of at least ﬁve consecutive time-steps that are all spiking or all silent.
That is the positive class (Fig.
1A, blue), whereas the negative class includes at most four consecutive ones or zeros (Fig.
1A, red).
We trained an LSTM model on this task with cross-entropy loss and RC.
When the positive-
[Figure]
A
B
C
D
E
F
G
[Figure]
class-related output activation crossed a threshold, we considered this a positive-class output spike, and vice versa for the negative class.
That ﬁrst spike’s label was used as the inferred label from the model for each input sequence (Fig. 1B), as described by RC inference.
In few cases, there was no output spike produced (Fig.
1B, grey).
These were speciﬁcally of the negative class, so they could be considered as negative inferred labels.
The RC-trained model achieved 100% accuracy, conﬁrming that training did work in terms of minimizing the explicit loss.
In addition, the positive spikes occurred in almost all cases at the earliest possible time-step relative to the ﬁve-step subsequences (Fig.
1C, blue spikes & black rectangles), showing that RC-training did optimize the timing aspect of the task as well.
The timing effect is visible also in negative examples, where the absence of a ﬁvestep-long continuous subsequence was recognized earlier than the last time step.
The importance of
RC during training becomes clear if we compare to the result of training the same network without
RC.
That is, we trained it with BPTT from the last time-step of each training example.
In this case, we could perform inference conventionally, at the end of the sequence.
However, attempting to perform early, i.e. RC, inference in a manner similar to the RC-trained model is problematic in this case.
The ﬁrst output spike is always negative (red) regardless of the true class, therefore the ﬁrst spike label cannot be used (Fig. 1F).
Label prediction in this case can be improved by a scheme where examples are considered negative unless a positive (blue) spike is output, whereas negative (red) spikes are ignored.
In terms of timing, the ﬁrst positive spikes are in fact emitted soon relative to the observation of a ﬁve-step subsequence, but still one step too late (Fig.
1F, bottom-most blue spikes).
Moreover, through this scheme, inference of negative labels cannot be performed before the full 25 steps of an input sequence are all observed.
Therefore, RC training is necessary for fastest inference, for less computation, and for sparseness of output spikes.
To gain deeper insight into the RC-trained network, we also study its activations before the application of the threshold and compare with the conventionally-trained model (Fig.
1D & G).
Interestingly, the RC model ﬂexibly adapts its belief throughout each input sequence based on available evidence.
In contrast, the nonRC model begins early on in the 25 steps to believe inputs as negative examples, and does not show signs of rapid adaptation to the changing input evidence.
This by-default negative (red) belief, and the slow switching of opinion cause comparatively low conﬁdence when the 5-step sequences are present (Fig.
1G, light blue).
Furthermore, the sparsity that we observed in terms of output spikes of the RC model is observable also at the pre-spike activations.
Both positive and negative activations remain low (light colours in Fig.
1F) until enough evidence appears.
In summary, RC-training solved both the classiﬁcation and the timing aspects of this task, while it also introduced sparsity in the network’s activity, and it reduced the computational steps in training and inference.
3. 2- SEQUENCE PROBLEM
[Figure]
I npu t v a l u e
[Figure]
The second task is inspired by the original “2-sequence problem” originally introduced in Bengio et al.
and adapted by Hochreiter & Schmidhuber (1997).
The task is to classify input sequences into one of two classes.
Each example of the positive class is a sequence of 40 independent samples from a Gaussian distribution centred at +0.05, whereas the negative class is centred at -0.
(Fig.
2A).
Each sequence has a constant standard deviation sampled uniformly from the range (0.05, 0.25).
These sequential inputs provide progressively more evidence on the underlying mean value, which is difﬁcult or impossible to infer correctly from a short sequence when the noise is high.
Here as well, we trained an LSTM model conventionally i.e. by back-propagating from the last time step of each sequence, and compared to our RC-training approach.
The RC-trained model, evaluated on a test set at the time of its ﬁrst spike, i.e. with RC-inference, achieved an accuracy of 95.45%.
This is lower than the 96.84% reached by the non-RC-trained model, when evaluated at the last, i.e. 40th, time-step.
However, the RC-trained model produced its RC-inference early, after 14 time-steps on average.
The accuracy of the non-RC-trained model, if evaluated at the 14th time-step, is much lower (89%).
Alternatively, we also tested the non-RC-trained model with RC-inference, and the model achieved a higher accuracy of 96.32%.
However, it was signiﬁcantly slower than the RCtrained model, with an average ﬁrst spike after 23 time-steps.
If we examine the distribution of the ﬁrst spike time as it changes throughout training, it can be seen that the RC-trained model becomes signiﬁcantly faster progressively (Fig.
2B, blue), which conﬁrms experimentally our theoretical result (Eq. 6) that RC-training optimizes timing.
Conversely, when the non-RC-trained model is evaluated with RC-inference throughout its training, it shows that conventional training has little effect on the timing distribution.
In this task, therefore, the RC-trained model achieves faster inference, by optimizing timing, albeit at the expense of accuracy.
As we have introduced in the paper’s theoretical section, it is theoretically possible to use a regularization that prevents over-optimization of timing at any cost.
We demonstrate this in the following more challenging tasks.
3. SNN BENCHMARKS ON TEMPORAL MNIST
[Figure]
The MNIST dataset is a common image-recognition benchmark.
It includes grey-scale images of handwritten digits, where each pixel is an intensity value between 0 and 255.
The task of classifying such digits into 10 classes is considered rather simple by modern ML standards.
However, more complex versions have been designed to match and demonstrate the temporal capabilities of SNNs, and contrast them to ANNs, by encoding the input temporally.
In a common such version (Coms¸a et al., 2021; Zhang et al., 2021;
Zhou et al., 2021; Mirsadeghi et al., 2021), each input pixel’s intensity is encoded by the timing of a single and binary spike in a time interval, where darker pixels spike earlier.
Some SNNs operate in continuous time, but here we use discrete time, and we encode each MNIST frame over 10 time steps (Fig.
3A).
Some of the recent SNN work has demonstrated that temporally coded SNNs can perform the task earlier than the end of each input sequence (Coms¸a et al., 2021; Zhang et al., 2021).
Of particular background interest is a ﬁnding in Coms¸a et al.
Speciﬁcally, temporal coding has two possible regimes when performing this task.
One regime is relatively slow but more accurate.
The other is a faster but less accurate regime, where on average less than 15% of the input frame’s duration has passed before inference.
As a result, in this task, for each reported accuracy, the regime of speed must be speciﬁed, as is indeed in Coms¸a et al.
A different, very recent work reports results outperforming those of Coms¸a et al.
, but does not mention the presence of two regimes.
It does show histograms of inference time, where it appears that the model is not in the fast regime, and it mentions a training time in the order of 100 epochs, at which point Coms¸a et al.
(2021) described that the network is at a high accuracy-low speed regime.
Here, we RC-trained an LSTM and a convolutional LSTM (ConvLSTM)
(Xingjian et al., 2015).
Firstly, the RC models did learn to perform inference in a very fast regime, on average immediately after the very ﬁrst input time-step (Fig.
3B).
Next, we conﬁrmed that our theoretical method of balancing the speed-accuracy trade-off, through an entropy-rewarding regularization term weighted by β , is effective.
By using a higher β during RC-training, the networks remained in a slower but more accurate regime.
By switching to a lower β value during training, the model switched to the faster but slightly less accurate regime.
Therefore, this validates the intended functionality of our regularization term, and also conﬁrms the presence of the two discrete regimes in this task (Fig.
3C).
These were observed in every network that we trained, and Fig.
3 B & C shows these effects in one of the models, namely a hidden layer of 20 ConvLSTM units, all-to-all connected to 10 output neurons with a softmax.
The speed-up is attributable to RC-training (see Appendix A.3).
Our models outperformed the SOTA SNNs in both the fast and the slow regime, except much larger and deeper SNNs that slightly outperformed ours.
Our models and their accuracies compared to the literature are presented in Table 1.
In addition, we could achieve high accuracy in the fast regime within only 50 epochs (Fig.
3B), while the existing SOTA in the fast regime required several hundreds of
[Table]
training epochs (Coms¸a et al., 2021)).
For all results, we used Adam with a learning rate ﬁxed at 0.001, and the threshold of 0.95.
The only hyperparameter value that we searched systematically was β .
These results are noteworthy because they achieve and surpass some of the advantages of
SNNs by using a spike-based technique, but avoiding the main difﬁculties of SNNs.
Moreover, RC enables a novel reduction of the resource requirements.
Speciﬁcally, it reduces the computation per training example or batch, as RC only backpropagates from the ﬁrst output spike.
In contrast, even in the temporal-coding SNN literature, all output neurons spike before backpropagation is applied.
3. R APID KEYWORD CLASSIFICATION - G OOGLE S PEECH C OMMANDS
The last and most advanced task that we addressed is a form of speech recognition.
Speciﬁcally, we used the Google Speech Commands dataset v0.02 (Warden, 2018).
This is a popular dataset containing 105,829 utterances of 35 different spoken terms from 2,618 speakers, and each of these recorded segments is at most 1-second long.
10 of the spoken terms (“Yes”, “No”, “Up”, “Down”, “Left”, “Right”, “On”, “Off”, “Stop” and “Go”) are selected as keywords, whereas the remaining 25 terms are combined into an 11th, “unknown” class.
We applied a preprocessing that is standard for this type of task, generating log-mel ﬁlterbank energies to extract constituent frequencies of the recording, and a moving window.
This resulted in 20 frequency-features over a sequence offrames.
We used a network with 128 LSTM units before two fully connected layers of 32 andneurons each, with a softmax at the output.
The training, validation and testing split of the dataset followed the convention provided in section 7 of Warden (2018).
We trained the model with RC, examining whether RC is effective in this task too, and then we compared to a baseline early inference after conventional training with BPTT from the end of each training sequence-example.
First, throughout training for 1000 epochs we looked into the accuracy of the model on the validation set, evaluated using RC-inference with the same spiking threshold (0.95) as was used for RC-training (Fig.
4A and C).
In parallel, we recorded the mean time-to-inference on the validation set, as deﬁned by the ﬁrst output spike time.
In one case we used standard cross-entropy loss, i.e. with the conﬁdence-regularization term β set to zero.
We observe that, in this case, spike time is signiﬁcantly reduced by RC-training, down to less than 500 ms on average, compared to the 1000 ms of the full speech sequences (Fig.
4C lightest blue curve).
In fact, training continues to minimize the spike time.
However, the validation accuracy (Fig.
4A, lightest blue) also decreases with training.
This is another expression of the effect that we observed in previous tasks, where continued minimization of the timing trades off accuracy.
To resolve that, we introduce a non-zero β regularization term, which achieves its goal to balance timing minimization against loss minimization.
Speciﬁcally, a β ≤ 0 .
3 increases the RC-inference validation accuracy compared to β = 0 .
However, it keeps the mean spike time delayed until the end of the sequence (Fig.
4A & C, darkest blue).
An intermediate value of β = 0 .
2 (medium-light blue curve) achieves a much better trade-off, where the validation accuracy is almost identical to the one achieved by β = 0 .
4 , but validation inference speed is signiﬁcantly higher, with a stably converged spike time of around 600 ms.
As a ﬁrst baseline, we compare these validation accuracies and speeds to a model trained with backpropagation from the last time-step of each sequence and without our regularization (i.e. β = 0 ).
This non-RC-
[Figure]
trained model, validated using RC-inference, reached a maximum accuracy that was lower than the accuracy of the best RC-trained models, and subsequently deteriorated fast (Fig.
4A, light green).
Importantly, even when evaluated, not on RC spiking early inference, but on conventional end-ofsequence inference, its validation accuracy (Fig.
4A, red curve) is not signiﬁcantly higher than the
RC-trained RC-inference
– the curve is rather indistinguishable.
This suggests that RC-training optimizes accuracy comparatively well, despite also focusing on the timing.
We will quantify this comparison to non-RC training and make it conclusive on the test set, but ﬁrst we will further analyse the non-RC training process.
As the best validation performance of the RC-trained models was achieved by incorporating a non-zero conﬁdence-regularization term β , we explored whether it is this regularization, rather than the RC-training itself, that is responsible for the seeming timing advantage of the RC-trained model.
Speciﬁcally, we trained with conventional backpropagation from the end of each sequence using cross-entropy but now added regularization to the loss function by β ∈ { 0 . 2 , 0 . 3 , 0 . 4 } , in addition to β = 0 as mentioned before.
We performed threshold-based early inference on the validation set throughout training, using the same conﬁdence threshold (0.95) as for the RC-trained models.
Different thresholds were explored in the analysis we describe later.
The resulting accuracy and speed curves are shown in Fig.
It can be seen that values of increasing β improves the convergence of the validation accuracy (Fig. 4B).
However, to converge to a stable level of accuracy, a β > 0 .
3 is required, which comes at a signiﬁcant cost of speed.
Therefore, β regularization alone does not sufﬁce to obtain the beneﬁts of RC-training.
Ultimately, most interesting in such an application is the quality of the resulting trade-off between speed and accuracy on the test dataset.
In addition, the tunability of this trade-off is important.
It is indeed possible to tune this trade-off by varying the threshold of the trained model, thus obtaining a varying accuracy as a function of inference time, i.e. spike time.
This is an existing approach in the literature (Sun et al., 2016; Dennis et al., 2018; Tan et al., 2021).
By lowering the threshold, faster inference is obtained for a cost of lower accuracy.
As a result, for each trained model, the curve representing the trade-off and its tunability is the curve of accuracy as a function of mean spike time.
This curve, for the case of the non-RC trained models, is shown in Fig.
5B. We used the network weights that produced the best validation accuracy throughout training (i.e. the maxima in Fig.
4B).
The models that were learned through different β values with conventional training had mostly similar trade-off curves among them.
To the contrary, in the case of RC-training, the trade-off curves were different for different values of β .
As a result, RC-training offers two methods for choosing the desired trade-off.
First, for a given trained model, the spiking threshold can be lowered for faster but less accurate inference (Fig.
5A, each blue curve), as in the conventional non-RC-trained models.
However, the accuracy drop by lowering the threshold is signiﬁcant, in both the RC- and the non-RCtrained cases.
RC-training offers a second method, with a smaller accuracy drop for faster inference.
By varying β while keeping the threshold at a ﬁxed high value, signiﬁcantly earlier inference is obtained for a much smaller drop or even slight increase in accuracy (Fig.
5A, red curve), as a result of RC-training.
Therefore, through RC-training, we have an additional option for tuning the speed of inference, and the model recognizes the spoken keywords with higher accuracy than the non-RCtrained model, at any desired speed setting.
It should be noted that the threshold-tuning can be used simultaneously with the β tuning method, as the two are orthogonal to each other and combinable.
Hence, more advanced threshold tuning mechanisms can be added after RC-training.
For example, it is possible to have a different threshold for each time-step through the input examples, and this set of multiple thresholds at the inference stage can be optimized for a certain increase in accuracy (Tan et al., 2021).
Here instead we explored the direction of incorporating timing into the training process.
Future work could combine RC-training with the literature’s mechanisms that also optimize the RCinference stage.
On θ during training, see Appendix B.
In summary, RC-training was again effective in optimizing the timing of inference, also in the time-critical application of keyword recognition within speech recordings.
It resulted in signiﬁcantly improved speed-accuracy trade-offs, and, in combination with an entropy-based regularizer, it improved the tunability of those trade-offs.
=0. =0.
=0. =0.
RC Composite
Non-
=0.
Composite
A
B =0.
=0. =0.
=0. =0.
=0. =0.
=0.
resulting composite best-trade-off curve is shown in red.
D ISCUSSION
All in all, we provided a theoretical motivation and a practical implementation for a spike-inspired technique that adaptively decreases computation and increases speed during both training and inference, while only trading off a small cost of accuracy, and offering ﬂexibility in choosing the desired speed-accuracy trade-off.
On the one hand, our results strengthen the case for research in spikebased networks, as they provide direct evidence for the beneﬁts of spikes.
This is supported by our comparisons of RC- to non-RC-training.
On the other hand, our results suggest that conventional
ANNs too can beneﬁt by integrating speciﬁc isolated spike-inspired elements.
For example, here spikes were used only in the output, and only their triggering aspect was used, while the remaining mechanisms were conventional RNNs and deep learning.
This careful isolation of a speciﬁc neuromorphic feature allowed us to better understand and demonstrate several of RC’s advantages, despite differences from Thorpe & Gautrais (1998).
Other recent work also provided direct evidence for the optimality of neuromorphic computing through focused application of very speciﬁc mechanisms (Leng et al., 2018; Moraitis et al., 2020).
In fact, the approach of identifying atomic neuromorphic computational elements, isolating them from surrounding related complexities and embedding them in otherwise conventional computational models, appears incremental but may be a more pragmatic path towards fully neuromorphic computing.
In addition to these broad implications, our results also imply more focused impact, namely on SOTA benchmarks for SNNs, on SOTA algorithms for fast inference, on the growing ﬁeld of adaptive computation with RNNs, and on speech recognition.
Therefore, further exploration of RC-RNNs may beneﬁt several different research directions.
DETAILS ON EXPERIMENTS A. C ONTINUOUS SEQUENCE SPOTTING
This experiment allows us to compare RC training to traditional EOS training in a noise-free controlled environment.
This is the only experiment in which there is an unambiguous optimal spike time step for each sequence.
This allows us to isolate the effect of RC training when evaluation the posterior probabilities and compare against a ground truth in terms of both classiﬁcation and timing.
Throughout this experiment we use a standard LSTM architecture with a hidden state of sizeand a projection to a single output neuron followed by a sigmoid activation.
We apply binary crossentropy loss and Adam optimiser Kingma & Ba (2014) with a learning rate of 0.0003.
In this experiment we set β =
meaning we do not use a conﬁdence penalty regularisation.
Data is generated in batches of size 128 with 1,500,000 training examples in total.
An independent validation set of 2000 sequences is evaluated after every 50 training batches.
We consider two distinct training approaches: our proposed rank-coded training and EOS training where just the ﬁnal model output is used for prediction.
The task is to produce a model that can robustly identify these continuous sequences as they occur where we consider any output greater than 0 .
95 as being a positive spike and any output less than 0 .
05 as being a negative spike.
A. 2- SEQUENCE PROBLEM
This dataset introduces an imperfect relationship between sequence values and class labels and allows us to consider the exact quantity of Gaussian noise added to a given sequence to be a proxy for its level of difﬁculty.
A desirable property of RC training would be to appropriately trade off speed and accuracy by providing a balance of both fast and accurate predictions.
Since each additional element of the sequence provides additional evidence of the sequence class, the optimal choice to maximise accuracy is to predict at the end of the sequence.
Therefore this problem allows us to compare RC training to traditional EOS training at trading off speed and accuracy.
In this experiment we use the same LSTM architecture, optimiser and hyperparameters as in the previous section.
We consider the same two training methods: RC training and EOS training.
We train both models on 2,000,000 training examples in batches of size 128 and retain the model that achieves the highest spiking accuracy on a validation set of size 2000 evaluated every 50 batches.
A. T EMPORAL MNIST
This problem is a standard benchmark for temporal coding schemes in the SNN literature.
This allows us to link our work to the existing body of research and compare performance.
Previous comparisons to ANNs in these works only considered non-recurrent neural networks which had no temporal aspect to their inference.
By introducing this task we can compare our proposed RC training in ANNs to SOTA approaches from the SNN literature while also controlling for speed of inference.
This provides a comparison between these ﬁelds on a task originally designed to exploit the temporal nature of SNNs.
We compare rank-coded training to SNN benchmarks by training a hidden layer 20 or 10 convolutional LSTM units or 340 LSTM units, and a projection layer of 10 neurons representing the
MNIST classes.
We also include the β -weighted conﬁdence penalty regularisation term to our loss calculation for the ﬁrst time.
For a fair comparison to the literature, we follow the experimental protocol taken in Coms¸a et al.
(2021) and Zhang et al.
(2021), as follows.
Each model is trained on the 60,000 MNIST training examples and test accuracy is reported on the testing set of 10,000 examples.
Unlike the large hyperparameter search, e.g. in Coms¸a et al.
(2021), we only required to search over a single hyperparameter β over which we completed a random search in the range [0 . 15 , 2] with the
LSTM model.
We found β = 0 .
165 as performing best on LSTM, and we then used it, without a separate search, also for training the convolutional LSTM.
With this hyperparameter, we trained each model twice, and we report the top accuracy on the test set. [Figure]
accurate despite very early outputs.
RC is the cause of early inference in Temporal MNIST, not the data or the network alone.
In
Section 3.3 we compared an RC-trained LSTM network to the current SOTA benchmarks in the temporal coding literature, showing it achieves fast and accurate inference. A reasonable follow-up question is whether the early inference in this case is not due to the learned RC, but rather only due to particularities in the speciﬁc dataset or properties of LSTM that SNN models don’t have. To evaluate this, we trained an LSTM network (784-340-10) with RC and compared to non-RCtraining. In the non-RC case, we calculated the loss and applied BPTT conventionally, from the end of the sequence, on the 10th and ﬁnal time step.
In Fig.
6A, we present the mean ﬁrst spike time when both methods are evaluated throughout the training process using RC inference with a ﬁxed threshold of 0.95.
The non-RC model does not minimize its timing throughout training, even if tested with RC inference, and even if trained for a much longer time.
The ﬁnal model from each method was then evaluated on the test set for a range of threshold values as displayed in Fig.
6B.
The ﬁrstspike accuracy for the RC-trained model is evaluated at threshold values θ ∈ { 0 . 85 , 0 .
95 , 0 . 99 } , while the non-RC model is evaluated at { 0 . 25 , 0 . 35 , 0 . 45 , 0 .
We observe that because the non-RC training objective is to maximize accuracy at the end of each input sequence, it is not incentivised to provide reasonable outputs much earlier in the sequence, even though there is enough exploitable information early.
RC-training, on the other hand, is implicitly optimizing the timing of its responses.
This provides evidence that the strong performance in this task is largely a function of the training mechanism rather than just a result of the dataset or of using an LSTM architecture.
A. R APID KEYWORD CLASSIFICATION - G OOGLE S PEECH C OMMANDS
This task is introduced to evaluate RC training on a popular sequential benchmark from the machine learning literature.
Classifying keywords in speech signals is, in principle, an excellent candidate for
RC training.
In most examples throughout this dataset the correct class can be predicted before the end of the sequence with any frames following the end of the keyword carrying no useful information and thus resulting in wasted computation.
This task provides the opportunity to evaluate if RC training can still achieve SOTA accuracy among recurrent models on this task while signiﬁcantly decreasing inference time.
In this experiment we selected standard choices (Zhang et al., 2017) for all preprocessing parameters using a hamming window function over a window of 25 ms with a stride of 10 ms and extractingmel coefﬁcients without applying padding.
We also include an input context of 10 frames on either side of the input frame as is common for RNNs on this dataset, see e.g. Sun et al.
This entire pipeline results in the full one-second sequences being 81 frames in length (after padding of the small fraction of sequences not consuming the full second).
Because some sequences in the dataset are shorter, the average sequence length before padding is 78 frames.
We also applied L 2 -norm gradient-clipping with a maximum of 0.25.
We applied early stopping to any model for which the spiking accuracy fell below the proportion of the majority class (non-keyword class) in the data.
This only occurred for the non-RC-trained model with β = 0 .
B (N ON -) EFFECT OF THE THRESHOLD CHOICE θ DURING RC TRAINING
Throughout this work we considered the threshold θ during RC training to be a ﬁxed hyperparameter.
In the training phase, the trade-off between resulting, i.e. inference, speed and accuracy is controlled by varying β .
We used a value of θ = 0 .
95 during training.
Once the model is trained, thus far, we have shown the possibility of also varying the threshold during inference as an additional mechanism to further tweak this trade-off (Fig. 5).
RC-training-threshold value
As an alternative approach, we also considered tuning the threshold during the training phase.
We found it to have only a minimal effect on performance.
As an example, in Fig. 7, we present the results of varying the threshold during training on the 2-sequence problem (Section 3.2 and
Appendix 3).
In this experiment, each model is trained as in Section 3.2, with a ﬁxed threshold throughout training.
Each of the following candidate threshold values was used: { 0.85, 0.9, 0.95, 0.99, 0.999 } .
Once trained, the model is tested on 100,000 random sequences using these thresholds, and the resulting trade-off curves for the different RC-training thresholds are shown in Fig.
As can be seen in the ﬁgure, the difference in performance between different training thresholds is minimal as long as the threshold is reasonably high.
C H IDDEN TEMPORAL DYNAMICS
Our implementation of temporal coding considers only the ﬁrst output spike, by applying a simple threshold-based rule.
However, the network manages to conform to this rule through more complex operations that implement a more complex temporal code in the recurrently connected population of neurons.
Essentially, the simplicity is in the supervisory interface for training the network, but, to map the input sequence to a well-timed and accurate summarizing spike, the network uses a more involved, multidimensional, i.e. multi-neuron, temporal encoding in the neurons’ hidden state and cell state.
An example of such hidden temporal dynamics can be seen in Fig.
8 in the response of the
RC-trained LSTM network to an example recording from the Google Speech Commands dataset.
[Figure]