O(1) Memory Online Learning¶
Train SNNs on arbitrarily long sequences without BPTT memory overhead.
E-prop Trainer¶
sc_neurocore.online_learning.eprop.EpropTrainer
dataclass
¶
E-prop online trainer for a single-layer recurrent SNN.
Parameters¶
n_inputs : int Input dimension. n_neurons : int Number of LIF neurons. n_outputs : int Output dimension. tau_mem : float Membrane time constant (ms). tau_trace : float Eligibility trace decay time constant (ms). threshold : float Spike threshold. lr : float Learning rate. dt : float Timestep (ms).
Source code in src/sc_neurocore/online_learning/eprop.py
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 73 74 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 106 107 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
memory_per_step
property
¶
Memory usage per timestep in parameters (O(1) in T).
reset()
¶
Reset all internal state and eligibility traces.
Source code in src/sc_neurocore/online_learning/eprop.py
84 85 86 87 88 89 90 91 | |
step(x, target=None)
¶
Process one timestep with optional learning.
Parameters¶
x : ndarray of shape (n_inputs,) Input spike vector or rates. target : ndarray of shape (n_outputs,), optional Target output for computing learning signal. If None, no learning.
Returns¶
dict with keys: 'spikes', 'output', 'loss' (if target given)
Source code in src/sc_neurocore/online_learning/eprop.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 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 148 149 150 | |
train_sequence(inputs, targets)
¶
Train on one sequence, return mean loss.
Parameters¶
inputs : ndarray of shape (T, n_inputs) targets : ndarray of shape (T, n_outputs)
Returns¶
float Mean loss over sequence.
Source code in src/sc_neurocore/online_learning/eprop.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
predict_sequence(inputs)
¶
Run inference on a sequence without learning.
Parameters¶
inputs : ndarray of shape (T, n_inputs)
Returns¶
ndarray of shape (T, n_outputs)
Source code in src/sc_neurocore/online_learning/eprop.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
Online LIF Layer¶
sc_neurocore.online_learning.online_trainer.OnlineLIFLayer
dataclass
¶
Single LIF layer with online (eligibility-based) learning.
Parameters¶
n_inputs : int n_neurons : int tau_mem : float Membrane time constant. threshold : float lr : float Learning rate for local weight updates.
Source code in src/sc_neurocore/online_learning/online_trainer.py
21 22 23 24 25 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 73 74 75 76 77 78 79 80 | |
step(x)
¶
Forward one timestep. Returns spike vector.
Source code in src/sc_neurocore/online_learning/online_trainer.py
58 59 60 61 62 63 64 65 66 67 68 69 | |
apply_learning_signal(signal)
¶
Apply a top-down learning signal to update weights.
Parameters¶
signal : ndarray of shape (n_neurons,) Per-neuron learning signal (e.g., error backprojected from output).
Source code in src/sc_neurocore/online_learning/online_trainer.py
71 72 73 74 75 76 77 78 79 80 | |
Online Trainer¶
sc_neurocore.online_learning.online_trainer.OnlineTrainer
dataclass
¶
Feedforward online trainer: stacks OnlineLIFLayers with eligibility learning.
Parameters¶
layer_sizes : list of int [n_input, n_hidden1, ..., n_output] tau_mem : float threshold : float lr : float
Source code in src/sc_neurocore/online_learning/online_trainer.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
memory_per_step
property
¶
Total parameters stored per timestep (O(1) in T).
step(x, target=None)
¶
Forward one timestep through all layers with optional learning.
Parameters¶
x : ndarray of shape (n_input,) target : ndarray of shape (n_output,), optional
Returns¶
dict with 'output' (final layer spikes) and optionally 'loss'
Source code in src/sc_neurocore/online_learning/online_trainer.py
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 | |
train_sequence(inputs, targets)
¶
Train on one sequence, return mean loss.
Source code in src/sc_neurocore/online_learning/online_trainer.py
149 150 151 152 153 154 155 156 157 | |