Synapses¶
Stochastic-computing synapses implement weighted connections between neurons using bitstream multiplication (AND gates).
| Class | Learning | Use case |
|---|---|---|
BitstreamSynapse |
None (static weight) | Inference, fixed networks |
StochasticSTDPSynapse |
Hebbian STDP | Unsupervised learning |
RewardModulatedSTDPSynapse |
Three-factor R-STDP | Reinforcement learning |
BitstreamDotProduct |
None | Multi-input weighted sum |
TripletSTDP |
Pfister-Gerstner 2006 | Rate-dependent cortical plasticity |
BCMSynapse |
Sliding threshold | Metaplasticity, selectivity |
ClopathSTDP |
Voltage-based | Unifies rate + timing plasticity |
TripartiteSynapse |
Astrocyte-modulated | Neuron-glia-synapse coupling |
GapJunction |
Electrical coupling | Interneuron synchrony |
Static Synapse¶
sc_neurocore.synapses.sc_synapse.BitstreamSynapse
dataclass
¶
Stochastic-computing synapse using bitstreams.
Each synapse has a weight w in [w_min, w_max]. SC multiplication via bitwise AND: P(out=1) ~ P(pre=1) * P(w=1).
Example¶
import numpy as np syn = BitstreamSynapse(w_min=0.0, w_max=1.0, w=0.5, length=1024, seed=42) pre = np.ones(1024, dtype=np.uint8) # all-ones input post = syn.apply(pre) abs(post.mean() - 0.5) < 0.1 # output ~50% ones True
Source code in src/sc_neurocore/synapses/sc_synapse.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
encode_weight(w)
¶
Encode scalar weight w into a unipolar bitstream.
Source code in src/sc_neurocore/synapses/sc_synapse.py
57 58 59 60 61 | |
update_weight(new_w)
¶
Change synaptic weight and recompute its bitstream.
Source code in src/sc_neurocore/synapses/sc_synapse.py
63 64 65 66 67 68 | |
apply(pre_bits)
¶
Apply synapse to a pre-synaptic bitstream.
Parameters¶
pre_bits : np.ndarray Bitstream of shape (length,) with values {0,1}.
Returns¶
np.ndarray Post-synaptic bitstream of shape (length,).
Source code in src/sc_neurocore/synapses/sc_synapse.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
effective_weight_probability()
¶
Decode the weight bitstream's probability P(weight_bit=1). This is the effective unipolar probability representation.
Source code in src/sc_neurocore/synapses/sc_synapse.py
92 93 94 95 96 97 | |
STDP Synapse¶
sc_neurocore.synapses.stochastic_stdp.StochasticSTDPSynapse
dataclass
¶
Bases: BitstreamSynapse
Stochastic synapse with spike-timing-dependent plasticity.
LTP on pre→post coincidence, LTD on pre-without-post. Asymmetry ratio from Bi & Poo, J. Neurosci. 18(24), 1998.
Example¶
syn = StochasticSTDPSynapse(w_min=0.0, w_max=1.0, w=0.5, length=64) for _ in range(100): ... syn.process_step(pre_bit=1, post_bit=1) # correlated activity → LTP syn.w >= 0.5 # weight increased or stayed True
Source code in src/sc_neurocore/synapses/stochastic_stdp.py
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 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 | |
process_step(pre_bit, post_bit)
¶
Process one timestep: compute output, update trace, apply STDP.
Source code in src/sc_neurocore/synapses/stochastic_stdp.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Reward-Modulated STDP¶
sc_neurocore.synapses.r_stdp.RewardModulatedSTDPSynapse
dataclass
¶
Bases: StochasticSTDPSynapse
Reward-modulated STDP synapse (Izhikevich, Cerebral Cortex 17(10), 2007).
Eligibility trace accumulates Hebbian coincidences; weight update fires only when a global reward signal arrives.
Example¶
syn = RewardModulatedSTDPSynapse(w_min=0.0, w_max=1.0, w=0.5, length=64) for _ in range(20): ... syn.process_step(pre_bit=1, post_bit=1) syn.apply_reward(reward=1.0) # positive reward → potentiate syn.w >= 0.5 True
Source code in src/sc_neurocore/synapses/r_stdp.py
14 15 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 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_reward(reward)
¶
Global reward signal triggers weight update.
Source code in src/sc_neurocore/synapses/r_stdp.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
Dot Product¶
sc_neurocore.synapses.dot_product.BitstreamDotProduct
dataclass
¶
Bitstream-level dot product via SC synapses.
For each input i, applies synapse_i (AND gate), then sums decoded probabilities: y ~ sum_i w_i * x_i.
Example¶
import numpy as np from sc_neurocore import BitstreamSynapse syns = [BitstreamSynapse(w_min=0.0, w_max=1.0, w=0.5, length=256) ... for _ in range(3)] dp = BitstreamDotProduct(synapses=syns) pre = np.ones((3, 256), dtype=np.uint8) post_matrix, y_scalar = dp.apply(pre) post_matrix.shape (3, 256)
Source code in src/sc_neurocore/synapses/dot_product.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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
apply(pre_matrix, y_min=0.0, y_max=1.0)
¶
Apply all synapses to the pre-synaptic bitstreams and compute a scalar 'dot-product-like' value.
Parameters¶
pre_matrix : np.ndarray Shape (n_inputs, length), entries {0,1}. y_min, y_max : float Range in which the final scalar output is interpreted (e.g., current range for the neuron).
Returns¶
post_matrix : np.ndarray Post-synaptic bitstreams of shape (n_inputs, length). y_scalar : float Scalar result representing sum_i P(post_i=1) mapped into [y_min, y_max].
Source code in src/sc_neurocore/synapses/dot_product.py
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 | |
Triplet STDP (Pfister-Gerstner 2006)¶
sc_neurocore.synapses.triplet_stdp.TripletSTDP
dataclass
¶
Triplet STDP synapse (Pfister-Gerstner 2006).
Parameters¶
tau_plus : float Pre-synaptic trace decay (ms). Default: 16.8 (visual cortex fit). tau_minus : float Post-synaptic trace decay (ms). Default: 33.7. tau_x : float Slow pre-synaptic trace decay (ms). Default: 101. tau_y : float Slow post-synaptic trace decay (ms). Default: 125. a2_plus : float Pair LTP amplitude. Default: 7.5e-10. a3_plus : float Triplet LTP amplitude. Default: 9.3e-3. a2_minus : float Pair LTD amplitude. Default: 7.0e-3. a3_minus : float Triplet LTD amplitude. Default: 2.3e-4. w_min : float Minimum weight. Default: 0.0. w_max : float Maximum weight. Default: 1.0.
Source code in src/sc_neurocore/synapses/triplet_stdp.py
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 | |
step(pre_spike, post_spike, dt=1.0)
¶
Advance one timestep.
Returns the current weight after update.
Source code in src/sc_neurocore/synapses/triplet_stdp.py
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 | |
BCM Metaplasticity (Bienenstock-Cooper-Munro 1982)¶
sc_neurocore.synapses.bcm.BCMSynapse
dataclass
¶
BCM synapse with sliding modification threshold.
Parameters¶
eta : float Learning rate. tau_theta : float Time constant for sliding threshold (ms). theta_init : float Initial threshold value. w_min, w_max : float Weight bounds.
Source code in src/sc_neurocore/synapses/bcm.py
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 | |
step(pre_rate, post_rate, dt=1.0)
¶
Advance one timestep.
Parameters¶
pre_rate : float Pre-synaptic firing rate (or spike indicator). post_rate : float Post-synaptic firing rate (or membrane proxy). dt : float Timestep in ms.
Returns¶
float Updated weight.
Source code in src/sc_neurocore/synapses/bcm.py
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 | |
Voltage-Based STDP (Clopath et al. 2010)¶
sc_neurocore.synapses.clopath_stdp.ClopathSTDP
dataclass
¶
Voltage-based STDP (Clopath et al. 2010).
Parameters¶
a_ltd : float LTD amplitude. Default: 14e-5 (Clopath 2010, Table 1). a_ltp : float LTP amplitude. Default: 8e-5. tau_x : float Pre-synaptic trace decay (ms). Default: 15. tau_minus : float Slow voltage trace decay (ms). Default: 10. tau_plus : float Fast voltage trace decay (ms). Default: 7. theta_minus : float LTD voltage threshold (mV). Default: -70.6 (rest). theta_plus : float LTP voltage threshold (mV). Default: -45.3 (depolarization). w_min, w_max : float Weight bounds.
Source code in src/sc_neurocore/synapses/clopath_stdp.py
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 | |
step(pre_spike, u_post, dt=1.0)
¶
Advance one timestep.
Parameters¶
pre_spike : bool Whether the pre-synaptic neuron spiked. u_post : float Post-synaptic membrane voltage (mV). dt : float Timestep in ms.
Returns¶
float Updated weight.
Source code in src/sc_neurocore/synapses/clopath_stdp.py
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 | |
Tripartite Synapse (Astrocyte Coupling)¶
sc_neurocore.synapses.tripartite.TripartiteSynapse
dataclass
¶
Synapse with bidirectional astrocyte coupling.
Parameters¶
base_weight : float Baseline synaptic weight. glut_per_spike : float IP3 production rate per pre-synaptic spike (µM/s). ca_threshold : float Astrocyte Ca²⁺ threshold for gliotransmitter release (µM). facilitation : float Multiplicative gain when astrocyte is active (> 1 for facilitation). depression_rate : float Weight depression rate when astrocyte Ca²⁺ is below threshold. w_min, w_max : float Weight bounds.
Source code in src/sc_neurocore/synapses/tripartite.py
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 | |
ca
property
¶
Current astrocyte Ca²⁺ concentration (µM).
ip3
property
¶
Current astrocyte IP3 concentration (µM).
step(pre_spike, post_spike, dt=0.01)
¶
Advance one timestep.
Parameters¶
pre_spike : bool Pre-synaptic spike. post_spike : bool Post-synaptic spike (unused in basic model, reserved for Hebbian extension). dt : float Timestep in seconds.
Returns¶
float Effective synaptic weight (base_weight * astrocyte modulation).
Source code in src/sc_neurocore/synapses/tripartite.py
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 | |
effective_weight()
¶
Current effective synaptic weight.
Source code in src/sc_neurocore/synapses/tripartite.py
116 117 118 | |
Gap Junction (Electrical Synapse)¶
sc_neurocore.synapses.gap_junction.GapJunction
dataclass
¶
Bidirectional electrical synapse.
Parameters¶
conductance : float Gap junction conductance g_c (nS). Typical: 0.01-1.0 nS. Bennett & Zukin, Neuron 2004. rectification : float Rectification factor in [0, 1]. 0 = fully bidirectional (ohmic), 1 = fully rectifying (current flows in one direction only). Default 0 (standard gap junction).
Source code in src/sc_neurocore/synapses/gap_junction.py
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 | |
current(v_pre, v_post)
¶
Compute gap junction current flowing INTO v_post.
I_gap = g_c * (V_pre - V_post) * rectification_factor
Positive current depolarizes post. The same junction produces equal and opposite current for the pre-synaptic neuron.
Source code in src/sc_neurocore/synapses/gap_junction.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
current_matrix(voltages, adjacency)
¶
Compute gap junction currents for a population.
Parameters¶
voltages : np.ndarray, shape (N,) Membrane voltages of all neurons. adjacency : np.ndarray, shape (N, N) Binary or weighted adjacency matrix. A[i,j] = 1 means neurons i and j are connected by a gap junction.
Returns¶
np.ndarray, shape (N,) Net gap junction current for each neuron.
Source code in src/sc_neurocore/synapses/gap_junction.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |