ngclearn.components.synapses package
Subpackages
- ngclearn.components.synapses.competitive package
- Submodules
- ngclearn.components.synapses.competitive.ART2ASynapse module
- ngclearn.components.synapses.competitive.SOMSynapse module
- ngclearn.components.synapses.competitive.hopfieldSynapse module
- ngclearn.components.synapses.competitive.simple_ART2ASynapse module
- ngclearn.components.synapses.competitive.vectorQuantizeSynapse module
- Module contents
- ngclearn.components.synapses.convolution package
- Submodules
- ngclearn.components.synapses.convolution.convSynapse module
- ngclearn.components.synapses.convolution.deconvSynapse module
- ngclearn.components.synapses.convolution.hebbianConvSynapse module
- ngclearn.components.synapses.convolution.hebbianDeconvSynapse module
- ngclearn.components.synapses.convolution.ngcconv module
- ngclearn.components.synapses.convolution.staticConvSynapse module
- ngclearn.components.synapses.convolution.staticDeconvSynapse module
- ngclearn.components.synapses.convolution.traceSTDPConvSynapse module
- ngclearn.components.synapses.convolution.traceSTDPDeconvSynapse module
- Module contents
- ngclearn.components.synapses.hebbian package
- Submodules
- ngclearn.components.synapses.hebbian.BCMSynapse module
- ngclearn.components.synapses.hebbian.STDPSynapse module
- ngclearn.components.synapses.hebbian.eventSTDPSynapse module
- ngclearn.components.synapses.hebbian.expSTDPSynapse module
- ngclearn.components.synapses.hebbian.gerstnerHebbianSynapse module
- ngclearn.components.synapses.hebbian.hebbianSynapse module
- ngclearn.components.synapses.hebbian.traceSTDPSynapse module
- Module contents
- ngclearn.components.synapses.modulated package
- ngclearn.components.synapses.patched package
Submodules
ngclearn.components.synapses.STPDenseSynapse module
- class ngclearn.components.synapses.STPDenseSynapse.STPDenseSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA dynamic dense synaptic cable; this synapse evolves according to short-term plasticity (STP) dynamics.
— Synapse Compartments: —inputs - input (takes in external signals)outputs - output signalsweights - current value matrix of synaptic efficaciesbiases - 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 usex - fraction of resources available after neurotransmitter depletionDynamics note:If tau_d >> tau_f and resources U are large, then synapse is STD-dominatedIf 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
ngclearn.components.synapses.alphaSynapse module
- class ngclearn.components.synapses.alphaSynapse.AlphaSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA 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 variabledg/dt = -g/tau_decay + h/tau_decayi_syn = g * (syn_rest - v) // g is g_syn and h is h_syn in this synapse implementationwhere: syn_rest is the post-synaptic reverse potential for this synapset_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 toweights - current value matrix of synaptic efficaciesbiases - 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)
ngclearn.components.synapses.denseSynapse module
- class ngclearn.components.synapses.denseSynapse.DenseSynapse(*args, **kwargs)[source]
Bases:
JaxComponentA 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 signalsweights - current value matrix of synaptic efficacies (strength values)biases - current value vector of synaptic bias values- 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 * in) * resist_scale) + bias
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)
mask – if non-None, a (multiplicative) mask is applied to this synaptic weight matrix
ngclearn.components.synapses.doubleExpSynapse module
- class ngclearn.components.synapses.doubleExpSynapse.DoubleExpSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA 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 variabledg/dt = -g/tau_decay + hi_syn = g * (syn_rest - v) // g is g_syn and h is h_syn in this synapse implementationwhere: syn_rest is the post-synaptic reverse potential for this synapset_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 toweights - current value matrix of synaptic efficaciesbiases - 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)
ngclearn.components.synapses.exponentialSynapse module
- class ngclearn.components.synapses.exponentialSynapse.ExponentialSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA 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 implementationwhere: syn_rest is the post-synaptic reverse potential for this synapset_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 toweights - current value matrix of synaptic efficaciesbiases - 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)
ngclearn.components.synapses.mpsSynapse module
- class ngclearn.components.synapses.mpsSynapse.MPSSynapse(*args, **kwargs)[source]
Bases:
JaxComponentA Matrix Product State (MPS) compressed synaptic cable.
This component represents a synaptic weight matrix decomposed into a contracted chain of low-rank tensor cores (also known as a Tensor Train). This architecture drastically reduces parameter counts for high-dimensional layers—from O(N*M) to O(N*K + M*K)—while maintaining high expressive power and biological plausibility through local error-driven updates.
References:Stoudenmire, E. Miles, and David J. Schwab. “Supervised learning withquantum-inspired tensor networks.” Advances in neural informationprocessing systems 29 (2016).Novikov, Alexander, et al. “Tensorizing neural networks.” Advances inneural information processing systems 28 (2015).Nuijten, W. W. L., et al. “A Message Passing Realization of ExpectedFree Energy Minimization.” arXiv preprint arXiv:2501.03154 (2025).Wilson, P. “Performing Active Inference with Explainable TensorNetworks.” (2024).Fields, Chris, et al. “Control flow in active inference systems.”arXiv preprint arXiv:2303.01514 (2023).— Synapse Compartments: —inputs - external input signal values (shape: batch_size x in_dim)outputs - transformed signal values (shape: batch_size x out_dim)pre - pre-synaptic latent state values for learning (shape: batch_size x in_dim)post - post-synaptic error signal values for learning (shape: batch_size x out_dim)core1 - first MPS tensor core (shape: 1 x in_dim x bond_dim)core2 - second MPS tensor core (shape: bond_dim x out_dim x 1)key - JAX PRNG key used for stochasticity- Parameters:
name – the string name of this component
shape – tuple specifying the shape of the latent synaptic weight matrix (number of inputs, number of outputs)
bond_dim – the internal rank or “bond dimension” of the MPS compression. Higher values increase expressive power at the cost of more parameters. (Default: 16)
batch_size – the number of samples in a concurrent batch (Default: 1)
- advance_state()[source]
Performs the forward synaptic transformation using MPS contraction.
The full transformation is equivalent to: outputs = inputs @ (Core1 * Core2), but computed via iterative contraction to maintain memory efficiency: 1. z = inputs contracted with Core1 (Batch x Bond_Dim) 2. outputs = z contracted with Core2 (Batch x Out_Dim)
- evolve(eta=0.01)[source]
Updates the MPS tensor cores using local error-driven (Hebbian) gradients.
This utilizes the ‘pre’ and ‘post’ compartments to update core1 and core2. Because the weights are factorized, the update to each core depends on the activity and errors projected through the other core, maintaining global consistency through local message passing.
- project_backward(error_signal)[source]
Projects an error signal backwards through the compressed synaptic cable.
This allows the passing of messages/gradients through the hierarchy without ever reconstructing the full dense weight matrix, ensuring O(N) complexity relative to the input/output dimensions.
- property weights
Reconstructs the full dense matrix from the MPS cores for analysis. Note: This is computationally expensive for high-dimensional layers.
ngclearn.components.synapses.staticSynapse module
- class ngclearn.components.synapses.staticSynapse.StaticSynapse(*args, **kwargs)[source]
Bases:
DenseSynapseA 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 - outputweights - 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)