Residual Blocks¶
SNN residual blocks for building 400+ layer deep spiking networks.
MembraneShortcutBlock— MS-ResNet: residual adds to membrane potential, not spikes. Block dynamical isometry. (Hu 2024, TNNLS — 482-layer SNN on CIFAR-10)SEWBlock— Activation-before-addition:spike(W@x) + x. (Fang 2021, NeurIPS)DeepSNNStack— Stack of residual blocks.block_type='ms'or'sew'..depthreports effective weight layers.
from sc_neurocore.residual import MembraneShortcutBlock, SEWBlock, DeepSNNStack
See Tutorial 78: Residual Blocks for usage examples.
sc_neurocore.residual.blocks
¶
SNN residual blocks enabling 400+ layer deep spiking networks.
MembraneShortcutBlock: MS-ResNet (Hu 2024, TNNLS). Bypasses inter-block LIF neuron. Block dynamical isometry ensures gradient norm equality.
SEWBlock: activation-before-addition (Fang 2021, NeurIPS).
Reference: MS-ResNet trained 482-layer SNN on CIFAR-10
MembraneShortcutBlock
¶
MS-ResNet residual block with membrane shortcut.
Skips the inter-block LIF neuron. Residual connection adds directly to membrane potential, not to spikes.
Parameters¶
n_features : int threshold : float tau_mem : float
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
forward(x)
¶
Forward pass: x -> W1 -> LIF -> W2 -> add residual -> LIF -> spikes.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
reset()
¶
Reset the block membrane potential to zero.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
70 71 72 | |
SEWBlock
¶
SEW-ResNet block: activation-before-addition.
spike(W@x) + x instead of spike(W@x + x). Prevents identity mapping issues in spiking residual networks.
Parameters¶
n_features : int threshold : float
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
forward(x)
¶
Forward: spike(W@x) + x (element-wise, clamped to [0,1]).
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
94 95 96 97 98 99 100 101 | |
reset()
¶
Reset the block membrane potential to zero.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
103 104 105 | |
DeepSNNStack
¶
Stack of residual blocks for building deep SNNs.
Parameters¶
n_features : int n_blocks : int block_type : str 'ms' for MembraneShortcut, 'sew' for SEW.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
n_blocks
property
¶
Return the number of residual blocks in the stack.
depth
property
¶
Return the effective depth (two weight layers per block).
forward(x)
¶
Propagate the input through every residual block in sequence.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
127 128 129 130 131 132 | |
reset()
¶
Reset the membrane potential of every block in the stack.
Source code in src/sc_neurocore/residual/blocks.py
| Python | |
|---|---|
134 135 136 137 | |