Synapses

The synapse is a key building block for connecting/wiring together the various component cells that one would use for characterizing a biomimetic neural system. These particular objects are meant to perform, per simulated time step, a specific type of transformation – such as a linear transform or a convolution – utilizing their underlying synaptic parameters. Most times, a synaptic cable will be represented by a set of matrices (or filters) that are used to conduct a projection of an input signal (a value presented to a pre-synaptic/input compartment) resulting in an output signal (a value that appears within one of its post-synaptic compartments). There are three general groupings of synaptic components in ngc-learn: 1) non-plastic static synapses (only perform fixed transformations of input signals); 2) non-plastic dynamic synapses (perform time-varying, input-dependent transformations on input signals); and 3) plastic synapses that carry out long-term evolution. Notably, plastic synapse components are typically associated with a local plasticity rule, e.g., a Hebbian-type update, that either is triggered online, i.e., at some or all simulation time steps, or by integrating a differential equation, e.g., via eligibility traces.

Non-Plastic Synapse Types

Static (Dense) Synapse

This synapse performs a linear transform of its input signals. Note that this synaptic cable does not evolve and is meant to be used for fixed value (dense) synaptic connections. Note that all synapse components that inherit from the DenseSynapse class support sparsification (via the p_conn probability of existence argument) to produce sparsely-connected synaptic connectivity patterns.

class ngclearn.components.StaticSynapse(*args, **kwargs)[source]

A static dense synaptic cable; no form of synaptic evolution/adaptation is in-built to this component.

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output
weights - current value matrix of synaptic efficacies
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)

  • 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 (resistance) 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 and > 0. will result in a sparser synaptic structure (lower values yield sparse structure)

advance_state()
reset()

Static Convolutional Synapse

This synapse performs a convolutional transform of its input signals. Note that this synaptic cable does not evolve and is meant to be used for fixed value convolution synaptic filters.

class ngclearn.components.ConvSynapse(*args, **kwargs)[source]

A base convolutional synaptic cable.

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals
filters - current value tensor of filter/kernel efficacies
biases - current base-rate/bias efficacies
Parameters:
  • name – the string name of this cell

  • x_shape – 2d shape of input map signal (component currently assumess a square input maps)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • bias_init – kernel to drive initialization of bias/base-rate values (Default: None, which turns off/disables biases)

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

  • resist_scale – a fixed (resistance) scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((K @ in) * resist_scale) + b where @ denotes convolution

  • batch_size – batch size dimension of this component

advance_state()[source]
reset()[source]

Static Deconvolutional Synapse

This synapse performs a deconvolutional transform of its input signals. Note that this synaptic cable does not evolve and is meant to be used for fixed value deconvolution/transposed convolution synaptic filters.

class ngclearn.components.DeconvSynapse(*args, **kwargs)[source]

A base deconvolutional (transposed convolutional) synaptic cable.

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals
filters - current value tensor of filter/kernel efficacies
biases - current base-rate/bias efficacies
Parameters:
  • name – the string name of this cell

  • x_shape – 2d shape of input map signal (component currently assumess a square input maps)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • bias_init – kernel to drive initialization of bias/base-rate values (Default: None, which turns off/disables biases)

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

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

  • batch_size – batch size dimension of this component

advance_state()[source]
reset()[source]

Dynamic Synapse Types

Exponential Synapse

This (chemical) synapse performs a linear transform of its input signals. Note that this synapse is “dynamic” in the sense that its efficacies are a function of their pre-synaptic inputs; there is no inherent form of long-term plasticity in this base implementation. Synaptic strength values can be viewed as being filtered/smoothened through an expoential kernel.

class ngclearn.components.ExponentialSynapse(*args, **kwargs)[source]

A dynamic exponential synaptic cable; this synapse evolves according to exponential synaptic conductance dynamics. Specifically, the conductance dynamics are as follows:

dg/dt = -g/tau_decay + gBar sum_k (t - t_k)
i_syn = g * (syn_rest - v) // g is g_syn in this synapse implementation
where: syn_rest is the post-synaptic reverse potential for this synapse
t_k marks time of -pre-synaptic k-th pulse received by post-synaptic unit
— Synapse Compartments: —
inputs - input (takes in external signals, e.g., pre-synaptic pulses/spikes)
outputs - output signals (also equal to i_syn, total electrical current)
v - coupled voltages from post-synaptic neurons this synaptic cable connects to
weights - current value matrix of synaptic efficacies
biases - current value vector of synaptic bias values
— Dynamic / Short-term Plasticity Compartments: —
g_syn - fixed value matrix of synaptic resources (U)
i_syn - derived total electrical current variable
Parameters:
  • name – the string name of this synapse

  • shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)

  • tau_decay – synaptic decay time constant (ms)

  • g_syn_bar – maximum conductance elicited by each incoming spike (“synaptic weight”)

  • syn_rest – synaptic reversal potential; note, if this is set to None, then this synaptic conductance model will no longer be voltage-dependent (and will ignore the voltage compartment provided by an external spiking cell)

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

  • resist_scale – a fixed (resistance) 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 and > 0. will result in a sparser synaptic structure (lower values yield sparse structure)

  • is_nonplastic – boolean indicating if this synapse permits plasticity adjustments (Default: True)

advance_state(t, dt)[source]
reset()[source]

Double-Exponential Synapse

This (chemical) synapse performs a linear transform of its input signals. Note that this synapse is “dynamic” in the sense that its efficacies are a function of their pre-synaptic inputs; there is no inherent form of long-term plasticity in this base implementation. Synaptic strength values can be viewed as being filtered/smoothened through a doubleexpoential / difference of two exponentials kernel.

class ngclearn.components.DoubleExpSynapse(*args, **kwargs)[source]

A dynamic double-exponential synaptic cable; this synapse evolves according to difference of two exponentials synaptic conductance dynamics. Specifically, the conductance dynamics are as follows:

dh/dt = -h/tau_rise + gBar sum_k (t - t_k) * (1/tau_rise - 1/tau_decay) // h is an intermediate variable
dg/dt = -g/tau_decay + h
i_syn = g * (syn_rest - v) // g is g_syn and h is h_syn in this synapse implementation
where: syn_rest is the post-synaptic reverse potential for this synapse
t_k marks time of -pre-synaptic k-th pulse received by post-synaptic unit
— Synapse Compartments: —
inputs - input (takes in external signals, e.g., pre-synaptic pulses/spikes)
outputs - output signals (also equal to i_syn, total electrical current)
v - coupled voltages from post-synaptic neurons this synaptic cable connects to
weights - current value matrix of synaptic efficacies
biases - current value vector of synaptic bias values
— Dynamic / Short-term Plasticity Compartments: —
g_syn - fixed value matrix of synaptic resources (U)
i_syn - derived total electrical current variable
Parameters:
  • name – the string name of this synapse

  • shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)

  • tau_decay – synaptic decay time constant (ms)

  • tau_rise – synaptic increase/rise time constant (ms)

  • g_syn_bar – maximum conductance elicited by each incoming spike (“synaptic weight”)

  • syn_rest – synaptic reversal potential; note, if this is set to None, then this synaptic conductance model will no longer be voltage-dependent (and will ignore the voltage compartment provided by an external spiking cell)

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

  • resist_scale – a fixed (resistance) 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 and > 0. will result in a sparser synaptic structure (lower values yield sparse structure)

  • is_nonplastic – boolean indicating if this synapse permits plasticity adjustments (Default: True)

advance_state(t, dt)[source]
reset()[source]

Alpha Synapse

This (chemical) synapse performs a linear transform of its input signals. Note that this synapse is “dynamic” in the sense that its efficacies are a function of their pre-synaptic inputs; there is no inherent form of long-term plasticity in this base implementation. Synaptic strength values can be viewed as being filtered/smoothened through a kernel that models more realistic rise and fall times of synaptic conductance..

class ngclearn.components.AlphaSynapse(*args, **kwargs)[source]

A dynamic alpha synaptic cable; this synapse evolves according to alpha synaptic conductance dynamics. Specifically, the conductance dynamics are as follows:

dh/dt = -h/tau_decay + gBar sum_k (t - t_k) // h is an intermediate variable
dg/dt = -g/tau_decay + h/tau_decay
i_syn = g * (syn_rest - v) // g is g_syn and h is h_syn in this synapse implementation
where: syn_rest is the post-synaptic reverse potential for this synapse
t_k marks time of -pre-synaptic k-th pulse received by post-synaptic unit
— Synapse Compartments: —
inputs - input (takes in external signals, e.g., pre-synaptic pulses/spikes)
outputs - output signals (also equal to i_syn, total electrical current)
v - coupled voltages from post-synaptic neurons this synaptic cable connects to
weights - current value matrix of synaptic efficacies
biases - current value vector of synaptic bias values
— Dynamic / Short-term Plasticity Compartments: —
g_syn - fixed value matrix of synaptic resources (U)
i_syn - derived total electrical current variable
Parameters:
  • name – the string name of this synapse

  • shape – tuple specifying shape of this synaptic cable (usually a 2-tuple with number of inputs by number of outputs)

  • tau_decay – synaptic decay time constant (ms)

  • g_syn_bar – maximum conductance elicited by each incoming spike (“synaptic weight”)

  • syn_rest – synaptic reversal potential; note, if this is set to None, then this synaptic conductance model will no longer be voltage-dependent (and will ignore the voltage compartment provided by an external spiking cell)

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

  • resist_scale – a fixed (resistance) 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 and > 0. will result in a sparser synaptic structure (lower values yield sparse structure)

  • is_nonplastic – boolean indicating if this synapse permits plasticity adjustments (Default: True)

advance_state(t, dt)[source]
reset()[source]

Short-Term Plasticity (Dense) Synapse

This synapse performs a linear transform of its input signals. Note that this synapse is “dynamic” in the sense that it engages in short-term plasticity (STP), meaning that its efficacy values change as a function of its inputs/time (and simulated consumed resources), but it does not provide any long-term form of plasticity/adjustment.

class ngclearn.components.STPDenseSynapse(*args, **kwargs)[source]

A dynamic dense synaptic cable; this synapse evolves according to short-term plasticity (STP) dynamics.

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals
weights - current value matrix of synaptic efficacies
biases - current value vector of synaptic bias values
— Short-Term Plasticity Compartments: —
resources - fixed value matrix of synaptic resources (U)
u - release probability; fraction of resources ready for use
x - fraction of resources available after neurotransmitter depletion
Dynamics note:
If tau_d >> tau_f and resources U are large, then synapse is STD-dominated
If tau_d << tau_f and resources U are small, then synases is STF-dominated
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)

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

  • resist_scale – a fixed (resistance) 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 and > 0. will result in a sparser synaptic structure (lower values yield sparse structure)

  • tau_f – short-term facilitation (STF) time constant (default: 750 ms); note that setting this to 0 ms will disable STF

  • tau_d – shoft-term depression time constant (default: 50 ms); note that setting this to 0 ms will disable STD

  • resources_int – initialization kernel for synaptic resources matrix

advance_state(t, dt)[source]
reset()[source]

Multi-Factor Learning Synapse Types

Hebbian rules operate in a local manner – they generally use information more immediately available to synapses in both space and time – and can come in a wide variety of flavors. One general way to categorize variants of Hebbian learning is to clarify what (neural) statistics/values they operate on, e.g, do they work with real-valued information or discrete spikes, and how many factors (or distinct terms) are involved in calculating the update to synaptic values by the relevant learning rule.

(Two-Factor) Hebbian Synapse

This synapse performs a linear transform of its input signals and evolves according to a strictly two-factor/term update rule. In other words, the underlying synaptic efficacy matrix is changed according to a product between pre-synaptic compartment values (pre) and post-synaptic compartment (post) values, which can contain any type of vector/matrix statistics. This particular synapse further features some tools for advanced forms of Hebbian descent/ascent (such as applying the Hebbian update via adaptive learning rates such as adaptive moment estimation, i.e., Adam).

class ngclearn.components.HebbianSynapse(*args, **kwargs)[source]

A 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 efficacies
biases - current value vector of synaptic bias values
key - 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 efficacies
dBiases - current delta vector containing changes to be applied to bias values
opt_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

advance_state()
evolve()[source]
reset()[source]

(Two-Factor) BCM Synapse

This synapse performs a linear transform of its input signals and evolves according to a multi-factor, Bienenstock-Cooper-Munro (BCM) update rule. The underlying synaptic efficacy matrix is changed according to an evolved synaptic threshold parameter theta and a product between pre-synaptic compartment values (pre) and a nonlinear function of post-synaptic compartment (post) values, which can contain any type of vector/matrix statistics.

class ngclearn.components.BCMSynapse(*args, **kwargs)[source]

A 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 efficacies
key - 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) variables
dWeights - current delta matrix containing changes to be applied to synapses
References:
Bienenstock, E. L., Cooper, L. N, and Munro, P. W. (1982). Theory for the
development of neuron selectivity: orientation specificity and binocular
interaction 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

advance_state()
evolve(t, dt)[source]
reset()[source]

(Two-Factor) Hebbian Convolutional Synapse

This synapse performs a convolutional transform of its input signals and evolves according to a two-factor update rule. The underlying synaptic filters are changed according to products between pre-synaptic compartment values (pre) and post-synaptic compartment (post) feature map values.

class ngclearn.components.HebbianConvSynapse(*args, **kwargs)[source]

A specialized synaptic convolutional 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 filters)
filters - current value matrix of synaptic filter efficacies
biases - current value vector of synaptic bias values
key - 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 - delta tensor containing changes to be applied to synaptic filter efficacies
dBiases - delta tensor containing changes to be applied to bias values
dInputs - delta tensor containing back-transmitted signal values (“backpropagating pulse”)
opt_params - locally-embedded optimizer statisticis (e.g., Adam 1st/2nd moments if adam is used)
Parameters:
  • name – the string name of this cell

  • x_shape – 2d shape of input map signal (component currently assumess a square input maps)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

  • eta – global learning rate (default: 0)

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • bias_init – kernel to drive initialization of bias/base-rate values (Default: None, which turns off/disables biases)

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

  • resist_scale – a fixed (resistance) scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((K @ in) * resist_scale) + b where @ denotes convolution

  • 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

  • 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

  • batch_size – batch size dimension of this component

advance_state()
evolve()[source]
reset()[source]

(Two-Factor) Hebbian Deconvolutional Synapse

This synapse performs a deconvolutional (transposed convolutional) transform of its input signals and evolves according to a two-factor update rule. The underlying synaptic filters are changed according to products between pre-synaptic compartment values (pre) and post-synaptic compartment (post) feature map values.

class ngclearn.components.HebbianDeconvSynapse(*args, **kwargs)[source]

A specialized synaptic deconvolutional (transposed convolutional) 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 filters)
filters - current value matrix of synaptic filter efficacies
biases - current value vector of synaptic bias values
key - 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 - delta tensor containing changes to be applied to synaptic filter efficacies
dBiases - delta tensor containing changes to be applied to bias values
dInputs - delta tensor containing back-transmitted signal values (“backpropagating pulse”)
opt_params - locally-embedded optimizer statisticis (e.g., Adam 1st/2nd moments if adam is used)
Parameters:
  • name – the string name of this cell

  • x_shape – dimension of input signal (assuming a square input)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

  • eta – global learning rate (default: 0)

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • bias_init – kernel to drive initialization of bias/base-rate values (Default: None, which turns off/disables biases)

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

  • resist_scale

    a fixed (resistance) scaling factor to apply to synaptic

    transform (Default: 1.), i.e., yields: out = ((W @.T Rscale) * in) + b where @.T denotes deconvolution

    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

  • 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

  • batch_size – batch size dimension of this component

advance_state()
evolve()[source]
reset()[source]

Spike-Timing-Dependent Plasticity (STDP) Synapse Types

Synapses that evolve according to a spike-timing-dependent plasticity (STDP) process operate, at a high level, much like multi-factor Hebbian rules (given that STDP is a generalization of Hebbian adjustment to spike trains) and share many of their properties. Nevertheless, a distinguishing factor for STDP-based synapses is that they must involve action potential pulses (spikes) in their calculations and they typically compute synaptic change according to the relative timing of spikes. In principle, any of the synapses in this grouping of components adapt their efficacies according to rules that are at least special four terms, i.e., a pre-synaptic spike (an “event”), a pre-synaptic delta timing (which can come in the form of a trace), a post-synaptic spike (or event), and a post-synaptic delta timing (also can be a trace). In addition, STDP rules in ngc-learn typically enforce soft/hard synaptic strength bounding, i.e., there is a maximum magnitude allowed for any single synaptic efficacy, and, by default, an STDP synapse enforces its synaptic strengths to be non-negative. Note: these rules are technically considered to be “two-factor” rules since they only operate on pre- and post-synaptic activity (despite each factor being represented by two or more terms).

Trace-based STDP

This is a four-term STDP rule that adjusts the underlying synaptic strength matrix via a weighted combination of long-term depression (LTD) and long-term potentiation (LTP). For the LTP portion of the update, a pre-synaptic trace and a post-synaptic event/spike-trigger are used, and for the LTD portion of the update, a pre-synaptic event/spike-trigger and a post-synaptic trace are utilized. Note that this specific rule can be configured to use different forms of soft threshold bounding including a scheme that recovers a power-scaling form of STDP (via the hyper-parameter mu).

class ngclearn.components.TraceSTDPSynapse(*args, **kwargs)[source]

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

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
key - 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 efficacies
eta - global learning rate (multiplier beyond A_plus and A_minus)
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)

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

advance_state()
evolve()[source]
reset()[source]

Exponential STDP

This is a four-term STDP rule that directly incorporates a controllable exponential synaptic strength dependency into its dynamics. This synapse’s LTP and LTD use traces and spike events in a manner similar to the trace-based STDP described above.

class ngclearn.components.ExpSTDPSynapse(*args, **kwargs)[source]

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

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
key - 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 efficacies
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)

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

advance_state()
evolve()[source]
reset()[source]

Event-Driven Post-Synaptic STDP Synapse

This is a synaptic evolved under a two-term STDP rule that is driven by only spike events and operates within a defined pre-synaptic “window” of time.

class ngclearn.components.EventSTDPSynapse(*args, **kwargs)[source]

A 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 efficacies
key - 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 efficacies
References:
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

advance_state()
evolve(t, dt)[source]
reset()[source]

Trace-based STDP Convolutional Synapse

This is a four-term STDP rule for convolutional synapses/kernels that adjusts the underlying filters via a weighted combination of long-term depression (LTD) and long-term potentiation (LTP). For the LTP portion of the update, a pre-synaptic trace and a post-synaptic event/spike-trigger are used, and for the LTD portion of the update, a pre-synaptic event/spike-trigger and a post-synaptic trace are utilized.

class ngclearn.components.TraceSTDPConvSynapse(*args, **kwargs)[source]

A specialized synaptic convolutional cable that adjusts its filter efficacies via a trace-based form of spike-timing-dependent plasticity (STDP).

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by filters)
filters - current value matrix of synaptic filter efficacies
biases - current value vector of synaptic bias values
eta - learning rate global scale
key - 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 - delta tensor containing changes to be applied to synaptic filter efficacies
dInputs - delta tensor containing back-transmitted signal values (“backpropagating pulse”)
Parameters:
  • name – the string name of this cell

  • x_shape – 2d shape of input map signal (component currently assumess a square input maps)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

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

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

  • eta – global learning rate (default: 0)

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

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

  • resist_scale – a fixed (resistance) scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((K @ in) * resist_scale) + b where @ denotes convolution

  • 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

  • w_decay – degree to which (L2) synaptic weight decay is applied to the computed STDP adjustment (Default: 0)

  • batch_size – batch size dimension of this component

advance_state()
evolve()[source]
reset()[source]

Trace-based STDP Deonvolutional Synapse

This is a four-term STDP rule for deconvolutional (transposed convolutional) synapses that adjusts the underlying filters via a weighted combination of long-term depression (LTD) and long-term potentiation (LTP). For the LTP portion of the update, a pre-synaptic trace and a post-synaptic event/spike-trigger are used, and for the LTD portion of the update, a pre-synaptic event/spike-trigger and a post-synaptic trace are utilized.

class ngclearn.components.TraceSTDPDeconvSynapse(*args, **kwargs)[source]

A specialized synaptic deconvolutional (transposed convolutional) cable that adjusts its filter efficacies via a trace-based form of spike-timing-dependent plasticity (STDP).

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by filters)
filters - current value matrix of synaptic filter efficacies
biases - current value vector of synaptic bias values
eta - learning rate global scale
key - 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 - delta tensor containing changes to be applied to synaptic filter efficacies
dInputs - delta tensor containing back-transmitted signal values (“backpropagating pulse”)
Parameters:
  • name – the string name of this cell

  • x_shape – dimension of input signal (assuming a square input)

  • shape – tuple specifying shape of this synaptic cable (usually a 4-tuple with number filter height x filter width x input channels x number output channels); note that currently filters/kernels are assumed to be square (kernel.width = kernel.height)

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

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

  • eta – global learning rate (default: 0)

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

  • filter_init – a kernel to drive initialization of this synaptic cable’s filter values

  • stride – length/size of stride

  • padding – pre-operator padding to use – “VALID” (none), “SAME”

  • resist_scale – a fixed (resistance) scaling factor to apply to synaptic transform (Default: 1.), i.e., yields: out = ((K @ in) * resist_scale) + b where @ denotes convolution

  • 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

  • w_decay – degree to which (L2) synaptic weight decay is applied to the computed STDP adjustment (Default: 0)

  • batch_size – batch size dimension of this component

advance_state()
evolve()[source]
reset()[source]

Modulated Forms of Plasticity

This family of synapses implemented within ngc-learn support modulated, often at least three-factor, forms of synaptic adjustment. Modulators could include reward/dopamine values or scalar error signals, and are generally assumed to be administered to the synapse(s) externally (i.e., it is treated as another input provided by some other entity, e.g., another neural circuit).

Reward-Modulated Trace-based STDP (MSTDP-ET)

This is a three-factor learning rule, i.e., pre-synaptic activity, post-synaptic activity, and a modulatory signal, known as modulated STDP (MSTDP). MSTDP adjusts the underlying synaptic strength matrix via a weighted combination of long-term depression (LTD) and long-term potentiation (LTP), scaled by an external signal such as a reward/dopamine value. The STDP element of this form of plasticity inherits from trace-based STDP (i.e. TraceSTDPSynapse). Note that this synapse component further supports a configuration for MSTDP-ET, or MSTPD with eligibility traces; MSTDP-ET means that the synapse will treat its synapses as two elements – a synaptic efficacy and a coupled synaptic trace that maintains the dynamics of STDP updates encountered over time.

class ngclearn.components.MSTDPETSynapse(*args, **kwargs)[source]

A synaptic cable that adjusts its efficacies via trace-based form of three-factor learning, i.e., modulated spike-timing-dependent plasticity (M-STDP) or modulated STDP with eligibility traces (M-STDP-ET).

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
modulator - external modulatory signal values (e.g., a reward value)
key - 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 (MS-STDP/MS-STDP-ET) changes to be applied to synaptic efficacies
eligibility - current state of eligibility trace
eta - global learning rate (applied to change in weights for final MS-STDP/MS-STDP-ET adjustment)
References:
Florian, Răzvan V. “Reinforcement learning through modulation of spike-timing-dependent synaptic plasticity.”
Neural computation 19.6 (2007): 1468-1502.

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)

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

  • tau_elg – eligibility trace time constant (default: 0); must be >0, otherwise, the trace is disabled and this synapse evolves via M-STDP

  • elg_decay – eligibility decay constant (default: 1)

  • tau_w – amount of synaptic decay to augment each MSTDP/MSTDP-ET update with

  • 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

  • w_bound – maximum value/magnitude any synaptic efficacy can be (default: 1)

advance_state()
evolve(dt, t)[source]
reset()[source]