ngclearn.components.synapses.competitive package

Submodules

ngclearn.components.synapses.competitive.ART2ASynapse module

class ngclearn.components.synapses.competitive.ART2ASynapse.ART2ASynapse(*args, **kwargs)[source]

Bases: DenseSynapse

A synaptic cable that emulates a simplified form of adaptive resonance theory (ART) adapted for continuous input signals (specifically, the ART2A-C model that handles real-valued input values).

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
i_tick - current internal tick / marker (gets incremented by 1 for each call to evolve)
eta - current learning rate value
key - JAX PRNG key
— Synaptic Plasticity Compartments: —
inputs - pre-synaptic signal/value to drive 1st term of ART2A update (x)
outputs - post-synaptic signal/value to drive 2nd term of ART2A update (y)
dWeights - current delta matrix containing changes to be applied to synapses
References:
Carpenter, Gail A., and Stephen Grossberg. “ART 2: Self-organization of stable category
recognition codes for analog input patterns.” Applied optics 26.23 (1987): 4919-4930.

Ororbia, Alexander G. “Continual competitive memory: A neural system for online task-free
lifelong learning.” arXiv preprint arXiv:2106.13300 (2021).
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 – (initial) learning rate / step-size for this ART2A model (initial condition value for eta)

  • eta_decrement – constant value to decrease eta by each call to this synapse’s evolve(), i.e., this triggers a linear schedule for decreasing eta by (Default: 0)

  • vigilance – vigilance parameter to decide if a memory vector is updated (rho)

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

  • p_conn – probability of a connection existing (default: 1.); setting this to < 1. will result in a sparser synaptic structure

advance_state()[source]
consolidate()[source]
evolve(t, dt)[source]
grow(n_memories)[source]
classmethod help()[source]
insert(x, idx)[source]
reset()[source]

ngclearn.components.synapses.competitive.SOMSynapse module

class ngclearn.components.synapses.competitive.SOMSynapse.SOMSynapse(*args, **kwargs)[source]

Bases: DenseSynapse

A synaptic cable that emulates a self-organizing map (or Kohonen map) that is adapted via competitive Hebbian learning. Many of this synapses internal compartments house dynamically-updated values for learning elements such as the SOM’s neighborhood radius and learning rate.

Mathematically, a synaptic update performed according to SOM theory is: | Delta W_{ij} = (x.T - W) * n(BMU) * eta | where n(BMU) is a neighborhood weighting function centered around (topological) coordinates of BMU | where x is vector of pre-synaptic inputs, W is SOM’s synaptic matrix, and BMU is best-matching unit for x

— Synapse Compartments: —
inputs - input (takes in external signals)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
bmu - current best-matching unit (BMU), based on current inputs
delta - current differences between inputs and each weight vector of this SOM’s synaptic matrix
i_tick - current internal tick / marker (gets incremented by 1 for each call to evolve)
eta - current learning rate value
radius - current radius value to control neighborhood function
key - JAX PRNG key
— Synaptic Plasticity Compartments: —
inputs - pre-synaptic signal/value to drive 1st term of SOM update (x)
outputs - post-synaptic signal/value to drive 2nd term of SOM update (y)
neighbor_weights - topology weighting applied to synaptic adjustments
dWeights - current delta matrix containing changes to be applied to synapses
References:
Kohonen, Teuvo. “The self-organizing map.” Proceedings of the IEEE 78.9 (2002): 1464-1480.
Parameters:
  • name – the string name of this cell

  • n_inputs – number of input units to this SOM

  • n_units_x – number of output units along length of rectangular topology of this SOM

  • n_units_y – number of output units along width of rectangular topology of this SOM

  • eta – (initial) learning rate / step-size for this SOM (initial condition value for eta)

  • distance_function – string specifying distance function to use for finding best-matching units (BMUs) (Default: “euclidean”). usage guide: “euclidean” = use L2 / Euclidean distance “manhattan” = use L1 / Manhattan / taxi-cab distance “cosine” = use cosine-similarity distance

  • neighbor_function – string specifying neighborhood function to compute approximate topology weighting across units in topology (based on BMU) (Default: “gaussian”). usage guide: “gaussian” = use Gaussian kernel “ricker” = use Mexican-hat / Ricker-Marr kernel

  • 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()[source]
evolve(t, dt)[source]
classmethod help()[source]
reset()[source]

ngclearn.components.synapses.competitive.hopfieldSynapse module

class ngclearn.components.synapses.competitive.hopfieldSynapse.HopfieldSynapse(*args, **kwargs)[source]

Bases: DenseSynapse

A synaptic cable that emulates a modern Hopfield network (MHN). Note that this model has been generalized a bit, a.l.a. NAC-Lab style, and comes equipped with two non-standard local plasticity update rules to alter the underlying memory matrix W from scratch (or to fine-tune an existing preloaded one); note that a mixed MHN can be created (one where initial patterns are stored but portions / elements of the memory matrix are further adapted in accordance to a local adjustment rule). This model currently only implements the exponential coupling/energy function.

— Synapse Compartments: —
inputs - input probe (takes in external signals)
outputs - output signals (retrieved memory / updated probe)
weights - current value matrix of synaptic efficacies
similarities - current raw similarity scores computed (pre-softmax)
memory_weights - current similarity scores computed (post-softmax)
i_tick - current internal tick / marker (gets incremented by 1 for each call to evolve)
energy - current energy functional reading (given current clamped input probe)
key - JAX PRNG key
— Synaptic Plasticity Compartments: —
dWeights - current delta matrix containing changes to be applied to synapses
References:
Movellan, Javier R. “Contrastive Hebbian learning in the continuous Hopfield model.” Connectionist models.
Morgan Kaufmann, 1991. 10-17.

Krotov, Dmitry, and John Hopfield. “Large associative memory problem in neurobiology and machine learning.”
arXiv preprint arXiv:2008.06996 (2020).

Hintzman, Douglas L. “MINERVA 2: A simulation model of human memory.” Behavior Research Methods, Instruments,
& Computers 16.2 (1984): 96-101.
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 – (initial) learning rate / step-size for this SOM (initial condition value for eta)

  • reg_lambda – weight decay coefficient applied to Hebbian update

  • beta – (inverse) temperature to control sharpness of memory similarity calculation

  • initial_patterns – seed patterns to store within memory matrix (Default: None)

  • update_rule – local plasticity rule to use to adjust/update memory matrix (Default: “delta”; Currently, two rules are encoded that work - a custom delta rule (prescribed error rule) and a custom contrastive Hebbian rule (Movellan/NAC-Lab-style)

  • 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()[source]
evolve(t, dt)[source]
classmethod help()[source]
reset()[source]

ngclearn.components.synapses.competitive.simple_ART2ASynapse module

ngclearn.components.synapses.competitive.vectorQuantizeSynapse module

class ngclearn.components.synapses.competitive.vectorQuantizeSynapse.VectorQuantizeSynapse(*args, **kwargs)[source]

Bases: DenseSynapse

A synaptic cable that emulates a vector quantization memory model (the base case of this model is referred to as “learning vector quantization”; LVQ).

— Synapse Compartments: —
inputs - input (takes in external signals)
labels - label input (optional)
outputs - output signals (transformation induced by synapses)
weights - current value matrix of synaptic efficacies
label_weights - current value of matrix label efficacies (if this VQ is supervised)
i_tick - current internal tick / marker (gets incremented by 1 for each call to evolve)
eta - current learning rate value
key - JAX PRNG key
— Synaptic Plasticity Compartments: —
inputs - pre-synaptic signal/value to drive 1st term of VQ update (x)
outputs - post-synaptic signal/value to drive 2nd term of VQ update (y)
labels - (optional) pre-synaptic signal to drive 1st term of VQ update to label matrix
dWeights - current delta matrix containing changes to be applied to synapses
References:
Somervuo, Panu, and Teuvo Kohonen. “Self-organizing maps and learning vector quantization for
feature sequences.” Neural Processing Letters 10.2 (1999): 151-159.

Kohonen, Teuvo. “The self-organizing map.” Proceedings of the IEEE 78.9 (2002): 1464-1480.

Ororbia, Alexander G. “Continual competitive memory: A neural system for online task-free
lifelong learning.” arXiv preprint arXiv:2106.13300 (2021).
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 – (initial) learning rate / step-size for this VQ model (initial condition value for eta)

  • eta_decrement – a constant value to linearly decrease eta by per synaptic update (Default: 0, which disables this)

  • syn_decay – a synaptic weight (L2) decay to apply to synapses per update

  • w_bound – upper soft bound to enforce over synapses post-update (Default: 0, which disables this scaling term)

  • distance_function – tuple specifying distance function and its order for computing best-matching units (BMUs) (Default: (“minkowski”, 2)). usage guide: (“minkowski”, 2) or (“euclidean”, ?) => use L2 norm (Euclidean) distance; (“minkowski”, 1) or (“manhattan”, ?) => use L1 norm (taxi-cab/city-block) distance; (“minkowksi”, jnp.inf) or (“chebyshev”, ?) => use Chebyshev distance; (“minkowski”, p > 2) => use a Minkowski distance of p-th order

  • label_dim – dimensionality of label neurons (corresponding to each memory/prototype); note this is inactive/unused if <= 0 (Default: 0)

  • initial_patterns – a tuple containing data vectors (and labels) to initialize code-book by; note if label_dim <= 0, then only first element of tuple will be used (Default: None)

  • langevin_noise_scale – scale factor to control degree to which Langevin sampling noise is applied to a given synaptic weight update (Default: 0, which disables this)

  • 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()[source]
evolve(t, dt)[source]
classmethod help()[source]
reset()[source]

Module contents