ngclearn.components.synapses.hebbian package

Submodules

ngclearn.components.synapses.hebbian.expSTDPSynapse module

class ngclearn.components.synapses.hebbian.expSTDPSynapse.ExpSTDPSynapse(*args: Any, **kwargs: Any)[source]

Bases: Component

A 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).

References:
Nessler, Bernhard, et al. “Bayesian computation emerges in generic cortical
microcircuits through spike-timing-dependent plasticity.” PLoS computational
biology 9.4 (2013): e1003037.

Bi, Guo-qiang, and Mu-ming Poo. “Synaptic modification by correlated
activity: 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)

  • eta – global learning rate

  • exp_beta – controls effect of exponential Hebbian shift/dependency

  • Aplus – strength of long-term potentiation (LTP)

  • Aminus – strength of long-term depression (LTD)

  • preTrace_target – controls degree of pre-synaptic disconnect, i.e., amount of decay (higher -> lower synaptic values)

  • wInit – 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, e.g., (“uniform”, -0.1, 0.1) samples U(-1,1) for each dimension/value of this cable’s underlying value matrix

  • key – PRNG key to control determinism of any underlying random values associated with this synaptic cable

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save synaptic parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(dt, t, **kwargs)[source]
evolve(dt, t, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
property outputCompartment
classmethod outputCompartmentName()[source]
property postsynapticTrace
classmethod postsynapticTraceName()[source]
property presynapticTrace
classmethod presynapticTraceName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
verify_connections()[source]
ngclearn.components.synapses.hebbian.expSTDPSynapse.compute_layer(inp, weight)

Applies the transformation/projection induced by the synaptic efficacie associated with this synaptic cable

Parameters:
  • inp – signal input to run through this synaptic cable

  • weight – this cable’s synaptic value matrix

Returns:

a projection/transformation of input “inp”

ngclearn.components.synapses.hebbian.expSTDPSynapse.evolve(dt, pre, x_pre, post, x_post, W, w_bound=1.0, eta=5e-05, x_tar=0.7, exp_beta=1.0, Aplus=1.0, Aminus=0.0, w_norm=None)

Evolves/changes the synpatic value matrix underlying this synaptic cable, given relevant statistics.

Parameters:
  • pre – pre-synaptic statistic to drive update

  • x_pre – pre-synaptic trace value

  • post – post-synaptic statistic to drive update

  • x_post – post-synaptic trace value

  • W – synaptic weight values (at time t)

  • w_bound – maximum value to enforce over newly computed efficacies

  • eta – global learning rate to apply to the Hebbian update

  • x_tar – controls degree of pre-synaptic disconnect

  • exp_beta – controls effect of exponential Hebbian shift/dependency

  • Aplus – strength of long-term potentiation (LTP)

  • Aminus – strength of long-term depression (LTD)

  • w_norm – if not None, applies an L2 norm constraint to synapses

Returns:

the newly evolved synaptic weight value matrix

ngclearn.components.synapses.hebbian.hebbianSynapse module

class ngclearn.components.synapses.hebbian.hebbianSynapse.HebbianSynapse(*args: Any, **kwargs: Any)[source]

Bases: Component

A synaptic cable that adjusts its efficacies via a two-factor Hebbian adjustment rule.

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

  • wInit – 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, e.g., (“uniform”, -0.1, 0.1) samples U(-1,1) for each dimension/value of this cable’s underlying value matrix

  • bInit – 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)

  • w_decay – degree to which (L2) synaptic weight decay is applied to the computed Hebbian adjustment (Default: 0); note that decay is not applied to any configured biases

  • signVal – 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.)

  • Rscale – a fixed scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((W * Rscale) * in) + b

  • key – PRNG key to control determinism of any underlying random values associated with this synaptic cable

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save synaptic parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(**kwargs)[source]
evolve(t, dt, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
property outputCompartment
classmethod outputCompartmentName()[source]
property postsynapticCompartment
classmethod postsynapticCompartmentName()[source]
property presynapticCompartment
classmethod presynapticCompartmentName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property trigger
classmethod triggerName()[source]
verify_connections()[source]
ngclearn.components.synapses.hebbian.hebbianSynapse.calc_update(pre, post, W, w_bound, is_nonnegative=True, signVal=1.0, w_decay=0.0, pre_wght=1.0, post_wght=1.0)

Compute a tensor of adjustments to be applied to a synaptic value matrix.

Parameters:
  • pre – pre-synaptic statistic to drive Hebbian update

  • post – post-synaptic statistic to drive Hebbian update

  • W – synaptic weight values (at time t)

  • w_bound – maximum value to enforce over newly computed efficacies

  • is_nonnegative – (Unused)

  • signVal – multiplicative factor to modulate final update by (good for flipping the signs of a computed synaptic change matrix)

  • w_decay – synaptic decay factor to apply to this update

  • pre_wght – pre-synaptic weighting term (Default: 1.)

  • post_wght – post-synaptic weighting term (Default: 1.)

Returns:

an update/adjustment matrix, an update adjustment vector (for biases)

ngclearn.components.synapses.hebbian.hebbianSynapse.compute_layer(inp, weight, biases, Rscale)

Applies the transformation/projection induced by the synaptic efficacie associated with this synaptic cable

Parameters:
  • inp – signal input to run through this synaptic cable

  • weight – this cable’s synaptic value matrix

  • biases – this cable’s bias value vector

  • Rscale – scale factor to apply to synapses before transform applied to input values

Returns:

a projection/transformation of input “inp”

ngclearn.components.synapses.hebbian.hebbianSynapse.enforce_constraints(W, w_bound, is_nonnegative=True)

Enforces constraints that the (synaptic) efficacies/values within matrix W must adhere to.

Parameters:
  • W – synaptic weight values (at time t)

  • w_bound – maximum value to enforce over newly computed efficacies

  • is_nonnegative – ensure updated value matrix is strictly non-negative

Returns:

the newly evolved synaptic weight value matrix

ngclearn.components.synapses.hebbian.traceSTDPSynapse module

class ngclearn.components.synapses.hebbian.traceSTDPSynapse.TraceSTDPSynapse(*args: Any, **kwargs: Any)[source]

Bases: Component

A 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).

References:
Morrison, Abigail, Ad Aertsen, and Markus Diesmann. “Spike-timing-dependent
plasticity in balanced random networks.” Neural computation 19.6 (2007): 1437-1467.

Bi, Guo-qiang, and Mu-ming Poo. “Synaptic modification by correlated
activity: 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)

  • eta – global learning rate

  • Aplus – strength of long-term potentiation (LTP)

  • Aminus – strength of long-term depression (LTD)

  • 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)

  • wInit – 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, e.g., (“uniform”, -0.1, 0.1) samples U(-1,1) for each dimension/value of this cable’s underlying value matrix

  • w_norm – if not None, applies an L1 norm constraint to synapses

  • norm_T – clocked time at which to apply L1 synaptic norm constraint

  • key – PRNG key to control determinism of any underlying random values associated with this synaptic cable

  • useVerboseDict – triggers slower, verbose dictionary mode (Default: False)

  • directory – string indicating directory on disk to save synaptic parameter values to (i.e., initial threshold values and any persistent adaptive threshold values)

advance_state(dt, t, **kwargs)[source]
evolve(dt, t, **kwargs)[source]
property inputCompartment
classmethod inputCompartmentName()[source]
load(directory, **kwargs)[source]
property outputCompartment
classmethod outputCompartmentName()[source]
property postsynapticTrace
classmethod postsynapticTraceName()[source]
property presynapticTrace
classmethod presynapticTraceName()[source]
reset(**kwargs)[source]
save(directory, **kwargs)[source]
property trigger
classmethod triggerName()[source]
verify_connections()[source]
ngclearn.components.synapses.hebbian.traceSTDPSynapse.compute_layer(inp, weight)

Applies the transformation/projection induced by the synaptic efficacie associated with this synaptic cable

Parameters:
  • inp – signal input to run through this synaptic cable

  • weight – this cable’s synaptic value matrix

Returns:

a projection/transformation of input “inp”

ngclearn.components.synapses.hebbian.traceSTDPSynapse.evolve(dt, pre, x_pre, post, x_post, W, w_bound=1.0, eta=1.0, x_tar=0.0, mu=0.0, Aplus=1.0, Aminus=0.0, w_norm=None)

Evolves/changes the synpatic value matrix underlying this synaptic cable, given relevant statistics.

Parameters:
  • pre – pre-synaptic statistic to drive update

  • x_pre – pre-synaptic trace value

  • post – post-synaptic statistic to drive update

  • x_post – post-synaptic trace value

  • W – synaptic weight values (at time t)

  • w_bound – maximum value to enforce over newly computed efficacies

  • eta – global learning rate to apply to the Hebbian update

  • x_tar – controls degree of pre-synaptic disconnect

  • mu – controls the power scale of the Hebbian shift

  • Aplus – strength of long-term potentiation (LTP)

  • Aminus – strength of long-term depression (LTD)

  • w_norm – (Unused)

Returns:

the newly evolved synaptic weight value matrix

Module contents