ngclearn.components.synapses.hebbian package
Submodules
ngclearn.components.synapses.hebbian.BCMSynapse module
- class ngclearn.components.synapses.hebbian.BCMSynapse.BCMSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA synaptic cable that adjusts its efficacies in accordance with BCM (Bienenstock-Cooper-Munro) theory.
Mathematically, a synaptic update performed according to BCM theory is: | tau_w d(W_{ij})/dt = -w_decay W_{ij} + x_j * [y_i * (y_i - theta_i)] / theta_i | tau_theta d(theta_i)/dt = -theta_i + <(y_i)^2>_{batch} | where x_j is the pre-synaptic input, y_i is the post-synaptic output
Note that, in most literature related to BCM, the average value used for threshold theta can be assumed to be the average over all input patterns (as in a full dataset batch update) but a temporal average maintained for theta will “usually be equivalent” (and ngc-learn implements the threshold theta in terms of a leaky ODE to dynamically compute the temporal mean).
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signals (transformation induced by synapses)weights - current value matrix of synaptic efficacieskey - JAX PRNG key— Synaptic Plasticity Compartments: —pre - pre-synaptic signal/value to drive 1st term of BCM update (x)post - post-synaptic signal/value to drive 2nd term of BCM update (y)theta - synaptic modification threshold (post-synaptic) variablesdWeights - current delta matrix containing changes to be applied to synapsesReferences:Bienenstock, E. L., Cooper, L. N, and Munro, P. W. (1982). Theory for thedevelopment of neuron selectivity: orientation specificity and binocularinteraction in visual cortex. Journal of Neuroscience, 2:32–48.- Parameters:
name – the string name of this cell
shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)
tau_w – synaptic update time constant
tau_theta – threshold variable evolution time constant
theta0 – initial condition for synaptic modification threshold
w_bound – maximum value to enforce over newly computed efficacies (default: 0.); must > 0. to be used
w_decay – synaptic decay factor (default: 0.)
weight_init – a kernel to drive initialization of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of initialization to use
resist_scale – a fixed scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((W * Rscale) * in)
p_conn – probability of a connection existing (default: 1.); setting this to < 1. will result in a sparser synaptic structure
ngclearn.components.synapses.hebbian.eventSTDPSynapse module
- class ngclearn.components.synapses.hebbian.eventSTDPSynapse.EventSTDPSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA synaptic cable that adjusts its efficacies via event-driven, post-synaptic spike-timing-dependent plasticity (STDP).
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signals (transformation induced by synapses)weights - current value matrix of synaptic efficacieskey - JAX PRNG key— Synaptic Plasticity Compartments: —pre_tols - pre-synaptic time-of-last-spike (tols) to drive 1st term of STDP update (takes in external values)postSpike - post-synaptic spike to drive 2nd term of STDP update (takes in external signals)dWeights - current delta matrix containing changes to be applied to synaptic efficaciesReferences:Tavanaei, Amirhossein, Timothée Masquelier, and Anthony Maida.“Representation learning using event-based STDP.” Neural Networks 105(2018): 294-303.- Parameters:
name – the string name of this cell
shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)
eta – global learning rate initial condition
lmbda – controls degree of synaptic disconnect (“lambda”)
A_plus – strength of long-term potentiation (LTP)
A_minus – strength of long-term depression (LTD)
presyn_win_len – pre-synaptic window time, or how far back in time to look for the presence of a pre-synaptic spike, in milliseconds (default: 1 ms)
w_bound – maximum value/magnitude any synaptic efficacy can be (default: 1)
weight_init – a kernel to drive initialization of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of initialization to use
resist_scale – a fixed scaling factor to apply to synaptic transform (Default: 1), i.e., yields: out = ((W * Rscale) * in) + b
p_conn – probability of a connection existing (default: 1.); setting this to < 1. will result in a sparser synaptic structure
ngclearn.components.synapses.hebbian.expSTDPSynapse module
- class ngclearn.components.synapses.hebbian.expSTDPSynapse.ExpSTDPSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA synaptic cable that adjusts its efficacies via trace-based form of spike-timing-dependent plasticity (STDP) based on an exponential weight dependence (the strength of which is controlled by a factor).
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signals (transformation induced by synapses)weights - current value matrix of synaptic efficacieskey - JAX PRNG key— Synaptic Plasticity Compartments: —preSpike - pre-synaptic spike to drive 1st term of STDP update (takes in external signals)postSpike - post-synaptic spike to drive 2nd term of STDP update (takes in external signals)preTrace - pre-synaptic trace value to drive 1st term of STDP update (takes in external signals)postTrace - post-synaptic trace value to drive 2nd term of STDP update (takes in external signals)dWeights - current delta matrix containing changes to be applied to synaptic efficaciesReferences:Nessler, Bernhard, et al. “Bayesian computation emerges in generic corticalmicrocircuits through spike-timing-dependent plasticity.” PLoS computationalbiology 9.4 (2013): e1003037.Bi, Guo-qiang, and Mu-ming Poo. “Synaptic modification by correlatedactivity: Hebb’s postulate revisited.” Annual review of neuroscience 24.1(2001): 139-166.- Parameters:
name – the string name of this cell
shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)
A_plus – strength of long-term potentiation (LTP)
A_minus – strength of long-term depression (LTD)
exp_beta – controls effect of exponential Hebbian shift/dependency
eta – global learning rate
pretrace_target – controls degree of pre-synaptic disconnect, i.e., amount of decay (higher -> lower synaptic values)
weight_init – a kernel to drive initialization of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of initialization to use
resist_scale – a fixed scaling (resistance) factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((W * Rscale) * in) + b
p_conn – probability of a connection existing (default: 1.); setting this to < 1. will result in a sparser synaptic structure
w_bound – maximum value/magnitude any synaptic efficacy can be (default: 1)
tau_w – synaptic weight decay coefficient to apply to STDP update
weight_mask – synaptic binary masking matrix to apply (to enforce a constant sparse structure; default: None)
ngclearn.components.synapses.hebbian.hebbianSynapse module
- class ngclearn.components.synapses.hebbian.hebbianSynapse.HebbianSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA synaptic cable that adjusts its efficacies via a two-factor Hebbian adjustment rule.
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signals (transformation induced by synapses)weights - current value matrix of synaptic efficaciesbiases - current value vector of synaptic bias valueskey - JAX PRNG key— Synaptic Plasticity Compartments: —pre - pre-synaptic signal to drive first term of Hebbian update (takes in external signals)post - post-synaptic signal to drive 2nd term of Hebbian update (takes in external signals)dWeights - current delta matrix containing changes to be applied to synaptic efficaciesdBiases - current delta vector containing changes to be applied to bias valuesopt_params - locally-embedded optimizer statisticis (e.g., Adam 1st/2nd moments if adam is used)- Parameters:
name – the string name of this cell
shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)
eta – global learning rate
weight_init – a kernel to drive initialization of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of initialization to use
bias_init – a kernel to drive initialization of biases for this synaptic cable (Default: None, which turns off/disables biases)
w_bound – maximum weight to softly bound this cable’s value matrix to; if set to 0, then no synaptic value bounding will be applied
is_nonnegative – enforce that synaptic efficacies are always non-negative after each synaptic update (if False, no constraint will be applied)
prior – a kernel to drive prior of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of prior to use and 2nd element as a floating point number calling the prior parameter lambda (Default: (‘constant’, 0.)) currently it supports “l1”/”lasso”/”laplacian” or “l2”/”ridge”/”gaussian” or “l1l2”/”elastic_net”. usage guide: prior = (‘l1’, 0.01) or prior = (‘lasso’, lmbda) prior = (‘l2’, 0.01) or prior = (‘ridge’, lmbda) prior = (‘l1l2’, (0.01, 0.01)) or prior = (‘elastic_net’, (lmbda, l1_ratio))
sign_value – multiplicative factor to apply to final synaptic update before it is applied to synapses; this is useful if gradient descent style optimization is required (as Hebbian rules typically yield adjustments for ascent)
optim_type –
optimization scheme to physically alter synaptic values once an update is computed (Default: “sgd”); supported schemes include “sgd” and “adam”
- Note:
technically, if “sgd” or “adam” is used but signVal = 1, then the ascent form of each rule is employed (signVal = -1) or a negative learning rate will mean a descent form of the optim_scheme is being employed
pre_wght – pre-synaptic weighting factor (Default: 1.)
post_wght – post-synaptic weighting factor (Default: 1.)
resist_scale – a fixed scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((W * Rscale) * in) + b
p_conn – probability of a connection existing (default: 1.); setting this to < 1. will result in a sparser synaptic structure
ngclearn.components.synapses.hebbian.traceSTDPSynapse module
- class ngclearn.components.synapses.hebbian.traceSTDPSynapse.TraceSTDPSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA synaptic cable that adjusts its efficacies via trace-based form of spike-timing-dependent plasticity (STDP), including an optional power-scale dependence that can be equipped to the Hebbian adjustment (the strength of which is controlled by a scalar factor).
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signals (transformation induced by synapses)weights - current value matrix of synaptic efficacieskey - JAX PRNG key— Synaptic Plasticity Compartments: —preSpike - pre-synaptic spike to drive 1st term of STDP update (takes in external signals)postSpike - post-synaptic spike to drive 2nd term of STDP update (takes in external signals)preTrace - pre-synaptic trace value to drive 1st term of STDP update (takes in external signals)postTrace - post-synaptic trace value to drive 2nd term of STDP update (takes in external signals)dWeights - current delta matrix containing changes to be applied to synaptic efficacieseta - global learning rate (multiplier beyond A_plus and A_minus)References:Morrison, Abigail, Ad Aertsen, and Markus Diesmann. “Spike-timing-dependentplasticity in balanced random networks.” Neural computation 19.6 (2007): 1437-1467.Bi, Guo-qiang, and Mu-ming Poo. “Synaptic modification by correlatedactivity: Hebb’s postulate revisited.” Annual review of neuroscience 24.1(2001): 139-166.- Parameters:
name – the string name of this cell
shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)
A_plus – strength of long-term potentiation (LTP)
A_minus – strength of long-term depression (LTD)
eta – global learning rate initial value/condition (default: 1)
mu – controls the power scale of the Hebbian shift
pretrace_target – controls degree of pre-synaptic disconnect, i.e., amount of decay (higher -> lower synaptic values)
weight_init – a kernel to drive initialization of this synaptic cable’s values; typically a tuple with 1st element as a string calling the name of initialization to use
resist_scale – a fixed scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((W * resistance) * in)
p_conn – probability of a connection existing (default: 1); setting this to < 1. will result in a sparser synaptic structure
w_bound – maximum value/magnitude any synaptic efficacy can be (default: 1)
tau_w – synaptic weight decay coefficient to apply to STDP update
weight_mask – synaptic binary masking matrix to apply (to enforce a constant sparse structure; default: None)