Beyond the Hamming Cliff: Compact Spatial Encodings Preserving Semantic Distance in Spiking Neural Networks
Authors: Sergio Davies, Muhammad Aitsam, Morgan-Tyler Stone, Alessandro Di Nuovo, Liangxiu Han
Organizations: Department of Computing and Mathematics, Manchester Metropolitan University, John Dalton Building, Oxford Road, Manchester, M15 6BH, United Kingdom · Centre of Excellence in Artificial Intelligence and Robotics, Sheffield Hallam University, Howard Street, Sheffield, S1 1WB, United Kingdom · Università degli Studi di Catania, Viale Andrea Doria 6, Catania, 95100, Italy
By pre-processing input signals with Gray, Thermometer, Johnson and hybrid encodings before passing them to spiking neural networks running on SpiNNaker hardware, Davies et al.(2025) address the semantic-spatial disparity that causes the ``Hamming cliff'' in standard binary representations. Continuous semantic patterns are presented as a set of simultaneous spikes at the input layer, preserving ultra-low latency processing. Training the network on multiple continuous values under each scheme, and measuring accuracy, required homeostatic scaling and false-positive rates, shows that removing the cliff is necessary but not sufficient: Gray encoding removes it yet retains little global distance structure, whereas Thermometer and Johnson preserve semantic distance at a code width that grows with the value range. The proposed hybrid encodings contain all three as limiting cases of a single parameter, recovering most of that structure at a fraction of the width. The homeostatic factor is shown to set a radius of tolerance around each trained pattern, so that the choice of encoding alone decides which values the network treats as similar.
Figures & tables
Representation
Decision available
Input events per value
How code distance relates to d
Rate
after an integration window
many, growing with precision
graded, in spike counts
Latency (time to first spike)
up to T , depending on the value
one per input neuron
graded, in spike times
Rank order
once enough of the order has arrived
one per neuron of the population
relative order across neurons, not the magnitude of one value
Population, Gaussian receptive fields
usually up to T , as fields are read out in time
several, one per active field
preserved locally; binarised to a window of k active neurons, H=2min(d,k) , saturating beyond the field width
One-hot (place)
one timestep
N
none: every distinct pair at H=2
Binary
one timestep
⌈log2N⌉
none, with cliffs at power-of-two boundaries
Table 1: Low-latency input representations compared on the three properties that distinguish a spatial code. Event counts are for a scalar of N levels; for the spatial codes every bit fires on one rail of its pair, so a code of width W delivers W events whatever its content. T is the length of the encoding window, d the semantic distance dS , and k the width of a binarised receptive field.
Parameter
Symbol
Value
Membrane time constant
τm
20 ms
Membrane capacitance
Cm
1.0 nF
Resting potential
Vrest
−65 mV
Reset potential
Vreset
−65 mV
Firing threshold
Vth
−50 mV a
Refractory period
τrefrac
0.1 ms
Table 2: Neuron, synapse and simulation parameters. Neuron values are the sPyNNaker defaults for IF_curr_delta , as logged on the hardware.
Figure 1: The network used for training. The pattern generator’s two neurons fire at the times encoding a “1” and a “0” respectively, and the code word of the presented value is realised as the connectivity between them and the dual-rail encoding populations (Section 3.2 ). In blue the STDP-enabled synapses, whose weights begin at zero; in orange the save neuron, which triggers the deferred weight updates; in red the teacher neuron, the only source of drive to the output neuron during training. Each encoding has its own pair of encoding populations and its own output neuron, and all eight share the generator, save and teacher neurons.
Figure 2: The network used for testing. The teacher and save neurons are removed and the learned weights are applied as static synapses, wired reciprocally so that a bit on which two trained code words disagree contributes equal excitation and inhibition and cancels exactly (Eq. 6 ). In red the excitatory synapses, in blue the inhibitory ones.
Metric
Formula
What it measures
Accuracy
tp+tn+fp+fntp+tn
the share of all values classified correctly; dominated by tn when few values are trained
Precision
tp+fptp
the share of accepted values that were trained
Negative prediction
tn+fntn
the share of rejected values that were untrained
Sensitivity
tp+fntp
the share of trained values that the network detects
Specificity
tn+fptn
the share of untrained values that the network rejects
Table 3: The five classification metrics used in Davies et al. (2025) , evaluated for every experiment and tabulated in full in Appendix A .
Encoding
Width
127
128
H
Binary
8
01111111
10000000
8
Gray
8
01000000
11000000
1
Thermometer
255
11270128
11280127
1
Hybrid lin. B=4
65
131034
132033
1
Hybrid lin. B=8
34
115019
116018
1
Johnson
128
112701
1128
1
Table 4: Code words of the canonical Hamming cliff pair 127 and 128 . Long codes are written in run-length form, 1a0b denoting a ones followed by b zeros.
v
b
r
refl.
coarse
fine
Δ
0
0
0
0
000
00
—
1
0
1
1
000
01
1
2
0
2
2
000
11
1
3
0
3
3
000
10
1
4
1
0
3
100
10
1
5
1
1
2
100
11
1
Table 5: The linear hybrid construction at N=16 and B=4 , giving a 5 -bit code: three coarse bits for the four blocks and two fine bits for the offset. For each value v , b=⌊v/B⌋ is the block it falls in and r=vmodB its offset within that block; “refl.” is the offset after reflection, equal to r in even blocks and to B−1−r in odd ones. “Coarse” is the Thermometer code of b and “fine” the Gray code of the reflected offset; the two concatenated form the code word. Because of the reflection the fine field runs 00,01,11,10 through block 0 and back again through block 1 , so that Δ , the number of bits that change from the previous value, is one everywhere, including at the block boundaries v=4 , 8 and 12 .
Figure 3: Hamming distance from the anchor value 240 to every value in 0 – 255 , under each of the eight encodings. Top row, the established codes; bottom row, the hybrids derived from them. Vertical scales differ between panels, since the code widths range from 8 to 255 bits: the comparison is of shape, not of magnitude.
Figure 4: Hamming distance H(f(i),f(j)) between every pair of values in 0 – 255 , under each of the eight encodings. Thermometer is a plane rising away from the diagonal, since H=∣i−j∣ exactly; Johnson folds that plane into a ridge, the distance falling again beyond N/2 as the values meet around the ring. The hybrids reproduce those shapes in stepped form, the step width being the block size. Binary and Gray are flat and textured: distance is roughly constant away from the diagonal and carries little information about separation. Vertical scales differ between panels, since the code widths range from 8 to 255 bits.
Linear
Cyclic
B
width
ρs
width
ρs
equivalent encoding
1
255
1.000
128
1.000
Thermometer / Johnson
2
128
1.000
65
0.999
4
65
0.998
34
0.996
8
34
0.990
19
0.980
16
19
0.956
12
0.911
Table 6: The hybrid family across block sizes at N=256 . ρs is Spearman’s correlation between Hamming and semantic distance, circular for the cyclic variant. B=1 coincides bit for bit with Thermometer and Johnson. From B=N/2 both variants coincide bit for bit with Gray, and their ρs values differ only because the cyclic variant is scored against circular distance. The cyclic variant reaches Gray’s Hamming distances one step earlier: at B=64 its coarse field is a two-bit Johnson ring, which is the two-bit Gray code with its bits swapped.
Radius, fraction of width
Encoding
2%
5%
10%
20%
Binary
7.5
7.5
7.5
23.9
Gray
7.0
7.0
7.0
21.1
Thermometer
1.0
1.0
1.0
1.0
Hybrid lin. B=4
3.0
3.9
3.7
3.4
Hybrid lin. B=8
3.9
6.8
7.6
6.7
Table 7: Neighbourhood fragmentation at four radii: the mean number of disjoint runs of consecutive values in the Hamming ball around each anchor, averaged over all 256 anchors. The radius is a fraction of the code width, with a floor of one bit; for the 8 -bit codes the three smaller fractions all fall below one bit, so their columns coincide. The text quotes the 10% column.
Hamming distance from the anchor 240
Second
Semantic
Linear family
Cyclic family
value v2
separation
Binary
Gray
Thermometer
B=4
B=8
Johnson
B=4
B=8
anchor 240
1404
103103
1240015
16005
13004
0112116
0281402
0141203
241
1
1
1
1
1
1
1
1
1
242
2
1
2
2
2
2
2
2
2
244
4
1
2
4
2
2
4
2
2
Table 8: The fourteen second values of Section 4.2 and their Hamming distance from the anchor 240 under each encoding, with their semantic separation ∣v2−240∣ for comparison. The groups are the close neighbours above the anchor, those below, progressively distant values, and the top of the range. Thermometer reproduces the separation exactly and Johnson its circular equivalent; the hybrids scale it by 1/B ; Binary and Gray bear no consistent relation to it. The code words of every value are listed in Table A.1 .
Encoding
Width
fp=H−1
excess
total fp
mean acc.
Binary
8
5/14
+26
93
0.9741
Gray
8
3/14
+6
29
0.9919
Thermometer
255
10/14
+2
630
0.8242
Hybrid lin. B=4
65
10/14
+1
155
0.9568
Hybrid lin. B=8
34
8/14
+1
81
0.9774
Johnson
128
14/14
+0
303
0.9155
Table 9: Two trained values: the anchor 240 together with each of the fourteen second values of Section 4.2 and Table 8 . If the network accepted exactly the code words lying between the two trained ones, the number of false positives would be H−1 , where H is the Hamming distance between them. “ fp=H−1 ” counts how many of the fourteen pairs meet this exactly; “excess” is the largest number of false positives above H−1 for any pair; “total fp ” and “mean acc.” are summed and averaged over the fourteen pairs.
Encoding
n=1
n=2
n=3
n=4
n=6
n=8
Homeostatic factor
Binary
5.18
6.94
6.95
3.48
2.32
1.74
Gray
5.17
2.96
2.30
1.73
1.39
1.04
Thermometer
2.47
1.24
0.84
0.63
0.43
0.32
Hybrid lin. B=4
2.15
1.09
0.74
0.56
0.38
0.29
Hybrid lin. B=8
2.11
1.09
0.75
0.57
0.39
0.29
Table 10: A contiguous cluster around 240, grown from one to eight trained values. Top: homeostatic factor. Middle: false positives over all 256 values. Bottom: the factor divided by f(1)/n , the value coherent summation would require – 1.00 means the summed weights reinforce perfectly, and the excess is the “don’t care” cancellation. Absolute factors are not comparable between encodings, because the output threshold is scaled with code width (Section 3.1 ): 8-bit codes sit near 5 and wide codes near 2 for that reason alone. Compare trends within a row, or the normalised values in the bottom block.
Encoding
total fp
median dist.
max dist.
within 4
Binary
154
8.9
142
25%
Gray
–
–
–
–
Thermometer
12
1.7
3
100%
Hybrid lin. B=4
10
2.2
4
100%
Hybrid lin. B=8
–
–
–
–
Johnson
–
–
–
–
Table 11: Semantic distance of the false positives from the trained cluster, pooled over all trained-set sizes. “within 4” is the share falling within four semantic units – the network generalising over a contiguous zone, as opposed to firing on unrelated values. Encodings with no false positives are marked “–”.
Encoding
W
exact
one shell more
partial
Binary
8
31/32
0
1
Gray
8
31/32
0
1
Thermometer
255
20/32
12
0
Hybrid lin. B=4
65
28/32
4
0
Hybrid lin. B=8
34
32/32
0
0
Johnson
128
32/32
0
0
Table 12: Accepted sets against the predicted Hamming ball of radius h=⌊W(1−1/m)/2⌋ , over all four targets and seven multipliers plus the minimum. “one shell more” counts cells in which the hardware accepted the next Hamming shell as well; “partial” counts cells at which the prediction falls exactly on a shell boundary.
Encoding
×1.1
×1.25
×1.5
×2.0
×3.0
×5.0
×8.0
Binary
1 (1)
1 (1)
9 (7)
37 (21)
37 (21)
93 (35)
93 (35)
Gray
1 (1)
1 (1)
9 (7)
37 (22)
37 (22)
93 (36)
93 (36)
Thermometer
25 (1)
42 (1)
58 (1)
80 (1)
101 (1)
118 (1)
127 (1)
Hybrid lin. B=4
20 (4)
36 (3)
52 (3)
76 (3)
96 (2)
116 (3)
124 (3)
Hybrid lin. B=8
6 (4)
27 (5)
44 (4)
68 (5)
92 (4)
108 (4)
116 (5)
Johnson
11 (1)
25 (1)
43 (1)
65 (1)
85 (1)
103 (1)
113 (1)
Table 13: Homeostatic tolerance, target 240. Each cell gives the number of values accepted and, in parentheses, the number of disjoint runs of consecutive values they form; (1) is a single semantic interval. Counts are limited by the end of the range, which lies only 15 values above the target. The multiplier scales each encoding’s own minimum factor.
Encoding
0
128
240
255
Binary
n/a
n/a
n/a
n/a
Gray
n/a
n/a
n/a
n/a
Thermometer
0
0
0
0
Hybrid lin. B=4
0
0
0
0
Hybrid lin. B=8
0
0
0
0
Johnson
32
0
17
32
Table 14: Values accepted only by going round the end of the range, at ×2.0 tolerance, by target. Only a cyclic encoding should accept any; the interior target 128 is a control at which none should. Binary and Gray are marked n/a: their accepted sets are scattered, so a value that happens to lie nearer by wrapping reflects a stray hit, not topology.
Encoding
Width
n=1
n=2
n=4
n=8
False positives
Binary
10
0
125
124
120
Gray
10
0
0
0
0
Hybrid lin. B=8
130
0
0
12
0
Hybrid lin. B=16
67
0
0
0
24
Hybrid cyc. B=8
67
0
0
0
16
Table 15: A contiguous cluster around 960 at N=1024 . Thermometer (1023 bits) and Johnson (512 bits) exceed the default input capacity of Section 3.4 at this range; the comparison is with the only established codes that fit within it. Top: false positives over all 1024 values. Bottom: the homeostatic factor relative to coherent summation, f(1)/n .
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Linear family
Cyclic family
Value
Binary
Gray
Thermometer
B=4
B=8
Johnson
B=4
B=8
240
11110000
10001000
1240015
16005
13004
0112116
0281402
0141203
241
11110001
10001001
1241014
160041
130031
0113115
0281401
01412021
242
11110010
10001011
1242013
1600312
1300212
0114114
02816
01412012
244
11110100
10001110
1244011
1610210
1300120
0116112
029140
014140
248
11111000
10000100
124807
16203
13202
012018
0301202
0151202
Appendix
Table A.1 : Code words of the anchor 240 and of the fourteen second values of Table 8 under each encoding. Long codes are written in run-length form, 1a0b denoting a ones followed by b zeros; the Hamming distances of Table 8 can be read off by comparing each row with the anchor.
v2
H
S
TP
TN
FP
FN
Acc.
Prec.
Neg. pred.
Sens.
Spec.
Binary (8 bits)
241
1
2.97
2
254
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
242
1
2.97
2
254
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
244
1
2.97
2
254
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
248
1
2.97
2
254
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
224
1
2.96
2
254
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
Appendix
Table A.2 : Two trained values: complete classification metrics. Anchor 240 trained together with v2 ; H is the Hamming distance between the two code words and S the homeostatic scaling factor. Counts are over all 256 values.
n
S
TP
TN
FP
FN
Acc.
Prec.
Neg. pred.
Sens.
Spec.
med. d
Binary (8 bits)
1
5.18
1
255
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
–
2
6.94
2
224
30
0
0.8828
0.0625
1.0000
1.0000
0.8819
8.0
3
6.95
3
207
46
0
0.8203
0.0612
1.0000
1.0000
0.8182
12.5
4
3.48
4
224
28
0
0.8906
0.1250
1.0000
1.0000
0.8889
7.5
6
2.32
6
224
26
0
0.8984
0.1875
1.0000
1.0000
0.8960
7.0
Appendix
Table A.3 : Growing trained sets: complete classification metrics. A contiguous cluster of n values around 240 is trained; S is the homeostatic scaling factor. “med. d ” is the median semantic distance of the false positives from the trained cluster.
n
S
TP
TN
FP
FN
Acc.
Prec.
Neg. pred.
Sens.
Spec.
Binary (10 bits)
1
4.14
1
1023
0
0
1.0000
1.0000
1.0000
1.0000
1.0000
2
6.95
2
897
125
0
0.8779
0.0157
1.0000
1.0000
0.8777
4
3.48
4
896
124
0
0.8789
0.0312
1.0000
1.0000
0.8784
8
1.75
8
896
120
0
0.8828
0.0625
1.0000
1.0000
0.8819
Gray (10 bits)
Appendix
Table A.4 : Extended range: complete classification metrics at N=1024 . Thermometer and Johnson exceed the default input capacity at this range and are not evaluated.
The mismatch between continuous acoustic signals and discrete event-driven processing remains a fundamental bottleneck for neuromorphic speech processing. Current systems typically rely on fixed spike encoders, forcing downstream Spiking Neural Networks (SNNs) to compensate for non-adaptive input representations. To address this, we present a learnable residual speech-to-spike encoder jointly trained end-to-end with a Recurrent Leaky Integrate-and-Fire (R-LIF) backbone. We validate this approach on the Google Speech Commands v2 (GSC-v2) benchmark, achieving up to 94.97% accuracy. Notably, the learned encoder remains highly parameter-efficient with a compact 35k-parameter variant that reaches 89.8%, matching or exceeding prior baselines that require an order of magnitude more parameters. Our encoder-focused analysis, including linear probing and gradient-residual inspection, indicates that the encoder does not target faithful signal reconstruction but instead learns task-aligned spike representations that enhance class separability. Finally, we benchmark bio-inspired, hardware-friendly credit assignment by comparing Direct Feedback Alignment (DFA) with surrogate-gradient BPTT under identical architectures and training conditions. We find that DFA reaches 91.5% accuracy, quantifying the performance trade-off of bio-inspired learning rules for modern neuromorphic audio.
Quantization is a natural complement to the sparse, event-driven computation of Spiking Neural Networks, reducing memory bandwidth and arithmetic cost for deployment on resource-constrained hardware. However, existing SNN quantization evaluation focuses almost exclusively on accuracy, overlooking whether a quantized network preserves the firing behavior of its full-precision counterpart. We demonstrate that quantization method, clipping range, and bit-width can produce substantially different firing distributions at equivalent accuracy, differences invisible to standard metrics but relevant to deployment, where firing activity governs effective sparsity, state storage, and event-processing load. To capture this gap, we propose Earth Mover's Distance as a diagnostic metric for firing distribution divergence, and apply it systematically across weight and membrane quantization on SEW-ResNet architectures trained on CIFAR-10 and CIFAR-100. We find that uniform quantization induces distributional drift even when accuracy is preserved, while LQ-Net style learned quantization maintains firing behavior close to the full-precision baseline. Our results suggest that behavior preservation should be treated as an evaluation criterion alongside accuracy, and that EMD provides a principled tool for assessing it.
Evan Gibson Smith, Jacob Whitehill, Fatemeh Ganji
Worcester Polytechnic Institute Worcester, Massachusetts, USA
This work proposes a hybrid ANN-SNN pipeline that effectively leverages the rich embeddings of pretrained artificial neural networks (ANNs) to enable high-performance spiking neural networks (SNNs). The architecture couples a pretrained EfficientNet encoder with a CoLaNET spiking classifier. We convert the encoder's activations into spike trains via rate-coding and train the subsequent SNN classifier using local, biologically inspired learning rules, bypassing end-to-end gradient propagation. This approach achieves 99.09% accuracy on a 64-class ImageNet benchmark, demonstrating performance on par with conventional deep networks. The work presents a biologically plausible and efficient framework for adapting powerful pretrained encoders to downstream spiking neural network tasks.