Layers¶
Pre-built layer compositions combining neurons, synapses, encoders, and recorders into reusable building blocks.
| Class | Architecture | Backend |
|---|---|---|
SCDenseLayer |
Fully-connected LIF | NumPy (loop-based) |
VectorizedSCLayer |
Fully-connected, packed bitwise | NumPy / CuPy GPU |
SCConv2DLayer |
2D convolution | NumPy |
SCRecurrentLayer |
Echo state / reservoir | NumPy |
SCLearningLayer |
Dense + online STDP | NumPy |
SCFusionLayer |
Multi-modal MUX fusion | NumPy |
StochasticAttention |
SC attention mechanism | NumPy |
MemristiveDenseLayer |
Memristive device model | NumPy |
JaxSCDenseLayer |
Fully-connected LIF | JAX (JIT, GPU/TPU) |
HardwareAwareSCLayer |
Dense + memristive defects | NumPy |
PredictiveCodingSCLayer |
XOR error, zero-multiplication | NumPy |
RallDendrite |
Compartmental dendritic tree | NumPy |
LateralInhibition |
Gaussian surround suppression | NumPy |
WinnerTakeAll |
k-WTA competitive layer | NumPy |
Dense Layer¶
SCDenseLayer accepts either a 1-D weight_values vector, which creates one
shared stochastic-computing current source for all neurons, or a 2-D
(n_neurons, n_inputs) weight matrix, which creates one SC dot-product source
per output neuron.
sc_neurocore.layers.sc_dense_layer.SCDenseLayer
dataclass
¶
Stochastic-computing dense layer of LIF neurons.
Each neuron receives SC dot-product input current and produces independent
spike trains. weight_values may be either a single shared vector of
length n_inputs or a dense matrix shaped (n_neurons, n_inputs).
Software-only but fully SC-driven at the input/synapse level.
Example¶
layer = SCDenseLayer( ... n_neurons=4, x_inputs=[0.5, 0.3], weight_values=[0.8, 0.6], ... x_min=0.0, x_max=1.0, w_min=0.0, w_max=1.0, length=256, ... ) layer.run(T=100) trains = layer.get_spike_trains() trains.shape (4, 100)
Source code in src/sc_neurocore/layers/sc_dense_layer.py
| Python | |
|---|---|
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
run(T)
¶
Run the layer for T time steps, updating all neurons.
A 1-D weight vector produces one shared SC current source for all neurons. A 2-D weight matrix produces one SC current source per neuron.
Source code in src/sc_neurocore/layers/sc_dense_layer.py
| Python | |
|---|---|
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
get_spike_trains()
¶
Return spike matrix of shape (n_neurons, T).
Source code in src/sc_neurocore/layers/sc_dense_layer.py
| Python | |
|---|---|
191 192 193 194 195 196 197 198 199 200 201 202 | |
summary()
¶
Return firing statistics for each neuron.
Source code in src/sc_neurocore/layers/sc_dense_layer.py
| Python | |
|---|---|
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
Vectorized Layer¶
sc_neurocore.layers.vectorized_layer.VectorizedSCLayer
dataclass
¶
High-performance SC layer using packed bitwise operations.
Uses GPU (CuPy) when available, otherwise pure NumPy.
Optional sparse connectivity via scipy.sparse.
Example¶
import numpy as np layer = VectorizedSCLayer(n_inputs=8, n_neurons=4, length=512) out = layer.forward(np.random.rand(8)) out.shape (4,) (out >= 0).all() and (out <= 1).all() True
Source code in src/sc_neurocore/layers/vectorized_layer.py
| Python | |
|---|---|
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
from_exported_weights(exported_layer, *, length=LAYER_DEFAULT_LENGTH, use_gpu=True, sparse=False, connectivity=1.0, sc_mode=None, seed=None)
classmethod
¶
Build a packed SC inference layer from to_sc_weights() output.
Source code in src/sc_neurocore/layers/vectorized_layer.py
| Python | |
|---|---|
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 201 | |
forward(input_values)
¶
Compute output firing rates for the layer.
Source code in src/sc_neurocore/layers/vectorized_layer.py
| Python | |
|---|---|
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
Convolutional Layer¶
sc_neurocore.layers.sc_conv_layer.SCConv2DLayer
dataclass
¶
SC 2D convolutional layer using stochastic probability encodings.
sc_mode="unipolar" accepts probabilities in [0, 1] and uses
probability-product accumulation. sc_mode="bipolar" accepts signed
values in [-1, 1] and uses signed XNOR-equivalent products.
Example¶
import numpy as np conv = SCConv2DLayer(in_channels=1, out_channels=2, kernel_size=3, padding=1) img = np.random.rand(1, 8, 8) out = conv.forward(img) out.shape (2, 8, 8)
Source code in src/sc_neurocore/layers/sc_conv_layer.py
| Python | |
|---|---|
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 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 | |
forward(input_image)
¶
input_image: (in_channels, H, W) Returns: (out_channels, H_out, W_out) as accumulated rates.
Source code in src/sc_neurocore/layers/sc_conv_layer.py
| Python | |
|---|---|
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 | |
Recurrent / Reservoir Layer¶
sc_neurocore.layers.recurrent.SCRecurrentLayer
dataclass
¶
SC recurrent / reservoir layer (echo state network).
Spectral radius bound follows Jaeger, GMD Report 148, 2001.
Example¶
import numpy as np res = SCRecurrentLayer(n_inputs=3, n_neurons=10, seed=0) state = res.step(np.array([0.5, 0.3, 0.8])) state.shape (10,)
Source code in src/sc_neurocore/layers/recurrent.py
| Python | |
|---|---|
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 81 82 83 84 | |
step(input_vector)
¶
Process one time step (e.g., one frame of audio). Input: (n_inputs,) Output: (n_neurons,) - New State
Source code in src/sc_neurocore/layers/recurrent.py
| Python | |
|---|---|
71 72 73 74 75 76 77 78 79 80 81 | |
Learning Layer¶
sc_neurocore.layers.sc_learning_layer.SCLearningLayer
dataclass
¶
SC dense layer with integrated STDP learning.
Each neuron has per-input STDP synapses. Plasticity follows Bi & Poo 1998 asymmetry convention.
Source code in src/sc_neurocore/layers/sc_learning_layer.py
| Python | |
|---|---|
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 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 | |
run_epoch(input_values)
¶
Run one bitstream epoch (length 'length').
Source code in src/sc_neurocore/layers/sc_learning_layer.py
| Python | |
|---|---|
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 | |
Fusion Layer¶
sc_neurocore.layers.fusion.SCFusionLayer
dataclass
¶
Fuses multiple data modalities using stochastic multiplexing (MUX).
Example¶
import numpy as np layer = SCFusionLayer( ... input_dims={"audio": 4, "visual": 4}, ... fusion_weights={"audio": 0.7, "visual": 0.3}, ... ) out = layer.forward({"audio": np.ones(4), "visual": np.zeros(4)}) out.shape (4,)
Source code in src/sc_neurocore/layers/fusion.py
| Python | |
|---|---|
18 19 20 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 | |
forward(inputs)
¶
inputs: {'modality': np.array([values])}
Source code in src/sc_neurocore/layers/fusion.py
| Python | |
|---|---|
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 | |
Attention Layer¶
sc_neurocore.layers.attention.StochasticAttention
dataclass
¶
Stochastic Computing Attention Block.
Two modes:
forward()— row-sum normalised (SC-native, no exp). Matches Rust engineforward().forward_softmax()— proper softmax with temperature scaling.
Example¶
Q = np.random.default_rng(0).uniform(0, 1, (4, 8)) K = np.random.default_rng(1).uniform(0, 1, (6, 8)) V = np.random.default_rng(2).uniform(0, 1, (6, 5)) attn = StochasticAttention(dim_k=8) attn.forward(Q, K, V).shape (4, 5) attn.forward_softmax(Q, K, V).shape (4, 5)
Source code in src/sc_neurocore/layers/attention.py
| Python | |
|---|---|
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 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 201 202 203 204 205 206 207 208 209 210 | |
forward(Q, K, V)
¶
Row-sum normalised attention (SC-native, no exp).
Parameters¶
Q : (N, dim_k) K : (M, dim_k) V : (M, dim_v)
Returns¶
(N, dim_v)
Source code in src/sc_neurocore/layers/attention.py
| Python | |
|---|---|
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
forward_softmax(Q, K, V)
¶
Proper softmax attention with temperature scaling.
softmax(Q @ K^T / temperature) @ V
Numerically stable via max-subtraction before exp.
Parameters¶
Q : (N, dim_k) K : (M, dim_k) V : (M, dim_v)
Returns¶
(N, dim_v)
Source code in src/sc_neurocore/layers/attention.py
| Python | |
|---|---|
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 | |
forward_bitstream(Q, K, V, length=1024, use_sobol=False)
¶
SC-native attention via bitstream AND gates.
Each element is encoded as a bitstream, inner products computed via AND (bit-level multiply), results decoded by popcount.
When use_sobol=True, Sobol low-discrepancy sequences replace Bernoulli random streams, reducing variance from O(1/√L) to O(1/L).
Parameters¶
Q : (N, dim_k) — query probabilities in [0, 1] K : (M, dim_k) — key probabilities in [0, 1] V : (M, dim_v) — value probabilities in [0, 1] length : int — bitstream length use_sobol : bool — use Sobol sequences for variance reduction
Returns¶
(N, dim_v) — attention output probabilities
Source code in src/sc_neurocore/layers/attention.py
| Python | |
|---|---|
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 201 202 203 204 205 206 207 208 209 210 | |
Memristive Layer¶
sc_neurocore.layers.memristive.MemristiveDenseLayer
dataclass
¶
Bases: VectorizedSCLayer
Dense layer mapped to a memristor crossbar with hardware non-idealities.
Defect parameters from Prezioso et al., Nature 521:61-64, 2015.
Source code in src/sc_neurocore/layers/memristive.py
| Python | |
|---|---|
16 17 18 19 20 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 | |
apply_hardware_defects()
¶
Corrupt weights based on physical properties.
Source code in src/sc_neurocore/layers/memristive.py
| Python | |
|---|---|
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
JAX Dense Layer¶
JaxSCDenseLayer accepts dense inputs shaped (n_inputs,) or (T, n_inputs)
and projects them through a validated (n_neurons, n_inputs) weight matrix.
It also accepts direct current vectors shaped (n_neurons,) or
(T, n_neurons) for low-level LIF experiments. Constructor and runtime inputs
validate dimensions, finite values, dense weight shape, known neuron parameter
keys, and JAX PRNG seed range before backend execution.
sc_neurocore.layers.jax_dense_layer.JaxSCDenseLayer
dataclass
¶
JAX-accelerated stochastic dense layer of LIF neurons.
Example¶
layer = JaxSCDenseLayer(n_neurons=10, n_inputs=5, seed=0) # doctest: +SKIP import jax.numpy as jnp # doctest: +SKIP spikes = layer.step(jnp.ones(10) * 0.5) # doctest: +SKIP spikes.shape # doctest: +SKIP (10,)
Source code in src/sc_neurocore/layers/jax_dense_layer.py
| Python | |
|---|---|
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
step(I_t)
¶
Advance the entire layer by one time step.
I_t: (n_neurons,) input current for each neuron. Returns: spikes: (n_neurons,) uint8 array.
Source code in src/sc_neurocore/layers/jax_dense_layer.py
| Python | |
|---|---|
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
run(currents)
¶
Run for multiple steps.
currents: (T, n_neurons) Returns: spikes: (T, n_neurons)
Source code in src/sc_neurocore/layers/jax_dense_layer.py
| Python | |
|---|---|
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
Hardware-Aware SC Layer¶
Trains around memristive defects (stuck-at faults) by masking gradients on defective synapses.
sc_neurocore.layers.hardware_aware.HardwareAwareSCLayer
dataclass
¶
SC layer with memristive hardware defect injection.
Parameters¶
n_inputs : int Number of input channels. n_neurons : int Number of output neurons. length : int Bitstream length. stuck_rate : float Fraction of synapses with stuck-at faults (0 or 1). Default 0.05. variability : float Additive weight noise std. Default 0.02. seed : int Random seed for defect generation.
Source code in src/sc_neurocore/layers/hardware_aware.py
| Python | |
|---|---|
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 | |
update_weights(gradient, lr=0.01)
¶
Update weights with gradient, respecting stuck-at mask.
Stuck synapses receive zero gradient — the network learns around the defects.
Source code in src/sc_neurocore/layers/hardware_aware.py
| Python | |
|---|---|
86 87 88 89 90 91 92 93 94 95 96 | |
Predictive Coding SC Layer (Conjecture C9)¶
Zero-multiplication predictive coding: XOR = error, popcount = magnitude, STDP = precision. First SC implementation of Bayesian prediction error minimization.
sc_neurocore.layers.predictive_coding.PredictiveCodingSCLayer
dataclass
¶
Zero-multiplication predictive coding in SC.
Parameters¶
n_inputs : int Number of input channels. n_neurons : int Number of predictive neurons. length : int Bitstream length. lr : float STDP-like learning rate for prediction weights. seed : int or None Random seed.
Source code in src/sc_neurocore/layers/predictive_coding.py
| Python | |
|---|---|
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 | |
forward(inputs)
¶
Process one timestep.
Parameters¶
inputs : array-like Input probabilities, shape (n_inputs,).
Returns¶
dict with keys: 'prediction_error': float — mean Hamming distance across neurons 'surprises': ndarray shape (n_neurons,) — per-neuron surprise 'predictions': ndarray shape (n_neurons, n_inputs) — predicted probs
Source code in src/sc_neurocore/layers/predictive_coding.py
| Python | |
|---|---|
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 | |
Rall Branching Dendrite¶
Compartmental dendritic tree with Rall's 3/2 power rule for impedance matching. Distal-to-proximal propagation with inter-compartment coupling.
sc_neurocore.layers.rall_dendrite.RallDendrite
dataclass
¶
Dendritic tree with Rall branching and compartmental dynamics.
Parameters¶
n_branches : int Number of dendritic branches. branch_length : int Number of compartments per branch. tau : float Membrane time constant (ms). coupling : float Inter-compartment coupling strength (0 to 1). dt : float Timestep (ms).
Source code in src/sc_neurocore/layers/rall_dendrite.py
| Python | |
|---|---|
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 | |
branch_voltages
property
¶
Current compartment voltages, shape (n_branches, branch_length).
step(branch_inputs)
¶
Advance one timestep.
Parameters¶
branch_inputs : np.ndarray Shape (n_branches,) — synaptic current injected at distal tip of each branch.
Returns¶
float Somatic voltage.
Source code in src/sc_neurocore/layers/rall_dendrite.py
| Python | |
|---|---|
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 | |
Lateral Inhibition¶
sc_neurocore.layers.circuit_primitives.LateralInhibition
dataclass
¶
Lateral inhibition: each neuron inhibits its neighbors.
Models the surround suppression found in retinal ganglion cells, cortical simple cells, and throughout sensory processing.
The inhibition kernel is a Gaussian centered on each neuron with
width radius, producing a Mexican-hat (center-surround) response
when combined with the neuron's own excitation.
Source code in src/sc_neurocore/layers/circuit_primitives.py
| Python | |
|---|---|
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 | |
apply(rates)
¶
Apply lateral inhibition to firing rates.
Parameters¶
rates : np.ndarray, shape (n_neurons,) Input firing rates or probabilities.
Returns¶
np.ndarray, shape (n_neurons,) Inhibited firing rates, clipped to [0, inf).
Source code in src/sc_neurocore/layers/circuit_primitives.py
| Python | |
|---|---|
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
Winner-Take-All¶
sc_neurocore.layers.circuit_primitives.WinnerTakeAll
dataclass
¶
k-Winner-Take-All circuit.
Only the top-k neurons remain active; all others are suppressed to zero. Models competitive dynamics in cortical columns and basal ganglia action selection.
With k=1, this is a hard argmax over the population.
Source code in src/sc_neurocore/layers/circuit_primitives.py
| Python | |
|---|---|
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 | |
apply(rates)
¶
Apply k-WTA to firing rates.
Parameters¶
rates : np.ndarray, shape (n_neurons,) Input firing rates.
Returns¶
np.ndarray, shape (n_neurons,) Only top-k values survive; rest are zero.
Source code in src/sc_neurocore/layers/circuit_primitives.py
| Python | |
|---|---|
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
winners(rates)
¶
Return indices of the k winning neurons.
Source code in src/sc_neurocore/layers/circuit_primitives.py
| Python | |
|---|---|
108 109 110 | |