stdp_nn_restr_synapse#
- class brainpy.state.stdp_nn_restr_synapse(weight=1.0, delay=Quantity(1., 'ms'), receptor_type=0, tau_plus=Quantity(20., 'ms'), tau_minus=Quantity(20., 'ms'), lambda_=0.01, alpha=1.0, mu_plus=1.0, mu_minus=1.0, Wmax=100.0, post=None, name=None)#
NEST-compatible
stdp_nn_restr_synapseconnection model.Short description
Synapse type for spike-timing dependent plasticity with restricted symmetric nearest-neighbour spike pairing.
Description
stdp_nn_restr_synapsemirrors NESTmodels/stdp_nn_restr_synapse.hand implements the restricted nearest-neighbor pairing scheme from Morrison et al. (2008, fig. 7C):On a presynaptic spike, depression uses the nearest preceding postsynaptic spike only if that postsynaptic spike occurred after the previous presynaptic spike,
On postsynaptic spikes, facilitation pairs only with the nearest preceding presynaptic spike that has not already been used for facilitation.
A spike therefore participates in at most one depression pair and at most one facilitation pair.
Compared with
stdp_synapse, this model changes two core STDP mechanisms:No running presynaptic
Kplustrace is used,Depression is nearest-neighbor and restricted to intervals where at least one postsynaptic spike occurred since the last presynaptic spike.
1. Mathematical Formulation
With normalized weight \(\hat w = w/W_{max}\):
\[\hat w \leftarrow \hat w + \lambda (1-\hat w)^{\mu_+} k_+\]\[\hat w \leftarrow \hat w - \alpha \lambda \hat w^{\mu_-} k_-\]with clipping to
[0, Wmax]in normalized coordinates, as in NEST.The potentiation trace factor for the restricted rule is:
\[k_+ = \exp\left(\frac{t_{\mathrm{last}} - (t_{post} + d)}{\tau_+}\right)\]where \(t_{\mathrm{last}}\) is the previous presynaptic spike time, \(t_{post}\) is the first postsynaptic spike time in the readout window, and \(d\) is the dendritic delay.
The depression trace factor is:
\[k_- = \exp\left(\frac{t_{post}^{\mathrm{nn}} - (t_{pre} - d)}{\tau_-}\right)\]where \(t_{post}^{\mathrm{nn}}\) is the nearest postsynaptic spike strictly before \(t_{pre} - d\).
2. Update Order (NEST Source Equivalent)
For a presynaptic spike at \(t_{pre}\) with dendritic delay \(d\), NEST
stdp_nn_restr_synapse::sendperforms:Read postsynaptic history in \((t_{\mathrm{last}}-d,\, t_{pre}-d]\).
If history is non-empty, facilitate once using the first postsynaptic spike in that interval: \(\exp((t_{\mathrm{last}}-(t_{post}+d))/\tau_+)\).
If history is non-empty, depress once using nearest-neighbor postsynaptic trace at \(t_{pre}-d\): \(\exp((t_{post}^{\mathrm{nn}}-(t_{pre}-d))/\tau_-)\).
Send event with updated
weight.Set
t_lastspike = t_pre.
This implementation preserves that exact ordering.
3. Coincidence Semantics
Pairs with exact coincidence are discarded by strict time comparisons (NEST
stdp_epsbehavior). Ifpresynaptic_spike == postsynaptic_spike + dendritic_delay, \(\Delta t = 0\) is not used; the nearest strictly earlier valid post-spike is used instead.4. Restricted Pairing Constraint
The “restricted” property ensures that a postsynaptic spike contributes to plasticity only if it occurred in the inter-spike interval between two consecutive presynaptic spikes. This prevents accumulation of plasticity from postsynaptic spikes that precede the synapse’s activation history.
- Parameters:
weight (
ArrayLike, optional) – Initial synaptic weight (scalar, float). Must have same sign asWmax. Default:1.0.delay (
ArrayLike, optional) – Synaptic delay (scalar, saiunit time). Dendritic delay for spike transmission. Default:1.0 * u.ms.receptor_type (
int, optional) – Receiver port/receptor id (non-negative integer). Identifies which input channel of the postsynaptic neuron this synapse targets. Default:0.tau_plus (
ArrayLike, optional) – Potentiation time constant (scalar, saiunit time, positive). Controls the temporal window for LTP. Default:20.0 * u.ms.tau_minus (
ArrayLike, optional) – Depression trace time constant (scalar, saiunit time, positive). Controls the temporal window for LTD. In NEST this belongs to the postsynaptic archiving neuron; here it is stored on the synapse for standalone compatibility. Default:20.0 * u.ms.lambda (
ArrayLike, optional) – Learning-rate parameter (scalar, float, positive). Global scaling factor for weight updates. Default:0.01.alpha (
ArrayLike, optional) – Depression scaling parameter (scalar, float, positive). Relative strength of LTD versus LTP. Default:1.0.mu_plus (
ArrayLike, optional) – Potentiation exponent (scalar, float, non-negative). Controls the weight-dependence of LTP.mu_plus=0gives additive LTP,mu_plus=1gives multiplicative LTP. Default:1.0.mu_minus (
ArrayLike, optional) – Depression exponent (scalar, float, non-negative). Controls the weight-dependence of LTD.mu_minus=0gives additive LTD,mu_minus=1gives multiplicative LTD. Default:1.0.Wmax (
ArrayLike, optional) – Maximum weight bound (scalar, float). Must have same sign asweight. Weights are clipped to the range[0, Wmax]or[Wmax, 0]depending on sign. Default:100.0.post (
object, optional) – Default receiver object. Must implement postsynaptic input methods. IfNone, must be specified insend()calls. Default:None.name (
str, optional) – Object name for identification. Default:None.
Parameter Mapping
The following table maps NEST parameter names to their brainpy.state equivalents:
NEST Parameter
brainpy.state
Notes
weightweightSynaptic efficacy
delaydelayDendritic delay (ms)
receptor_typereceptor_typeTarget receptor port
tau_plustau_plusLTP time constant (ms)
tau_minustau_minusLTD time constant (ms)
lambdalambda_Learning rate
alphaalphaLTD scaling factor
mu_plusmu_plusLTP weight-dependence exponent
mu_minusmu_minusLTD weight-dependence exponent
WmaxWmaxMaximum weight bound
t_lastspiket_lastspikePrevious presynaptic spike time
Notes
In NEST,
tau_minusis a postsynaptic-neuron parameter.As in NEST, STDP updates are based on on-grid spike stamps and ignore sub-step precise offsets.
Kplusis not a parameter of this model (unlikestdp_synapse).The restriction mechanism ensures each spike participates in at most one pair of each type (facilitation and depression).
Examples
Create a restricted nearest-neighbor STDP synapse:
>>> import brainpy.state as bst >>> import saiunit as u >>> syn = bst.nn.stdp_nn_restr_synapse( ... weight=0.5, ... delay=1.5 * u.ms, ... tau_plus=20.0 * u.ms, ... tau_minus=20.0 * u.ms, ... lambda_=0.01, ... alpha=1.0, ... mu_plus=1.0, ... mu_minus=1.0, ... Wmax=100.0 ... )
Configure asymmetric learning rates:
>>> syn = bst.nn.stdp_nn_restr_synapse( ... weight=1.0, ... lambda_=0.005, ... alpha=1.05, # Slightly stronger depression ... mu_plus=0.0, # Additive LTP ... mu_minus=1.0 # Multiplicative LTD ... )
References
- get()[source]#
Return current public parameters and mutable state.
Returns the NEST-compatible parameter dictionary for this synapse, excluding
Kplus(which is not used in this model).- Returns:
Dictionary containing all public parameters and mutable state:
weight,delay,receptor_type,tau_plus,tau_minus,lambda,alpha,mu_plus,mu_minus,Wmax,t_lastspike, andsynapse_model.- Return type:
Notes
The returned dictionary has
synapse_model='stdp_nn_restr_synapse'for NEST compatibility.Kplusis removed from the parent class’s output since it is not part of the restricted nearest-neighbor pairing scheme.
- send(multiplicity=1.0, *, post=None, receptor_type=None)[source]#
Schedule one outgoing event with NEST
stdp_nn_restr_synapsedynamics.Implements the restricted nearest-neighbor STDP pairing rule. On each presynaptic spike:
Reads postsynaptic spike history in the interval \((t_{\mathrm{last}}-d,\, t_{pre}-d]\).
If the history is non-empty:
Applies facilitation (LTP) using the first postsynaptic spike in the interval.
Applies depression (LTD) using the nearest-neighbor postsynaptic trace.
Schedules the spike event with updated weight for delivery after the dendritic delay.
Updates
t_lastspiketo the current spike time.
- Parameters:
multiplicity (
ArrayLike, optional) – Scalar event weight multiplier (e.g., spike count). If zero or very small, no event is sent. Default:1.0.post (
object, optional) – Target receiver object. IfNone, uses the default receiver set during initialization. Must implement postsynaptic input methods.receptor_type (
ArrayLike, optional) – Target receptor port (non-negative integer). IfNone, usesself.receptor_type. Default:None.
- Returns:
Trueif an event was scheduled,Falseifmultiplicitywas zero and no event was sent.- Return type:
Notes
Restricted pairing: Both LTP and LTD are applied only if at least one postsynaptic spike occurred between the previous and current presynaptic spikes.
Facilitation: Uses the first postsynaptic spike in the readout window with trace factor \(\exp((t_{\mathrm{last}} - (t_{post} + d))/\tau_+)\).
Depression: Uses the nearest-neighbor postsynaptic trace at \(t_{pre} - d\).
Event timing: Uses on-grid spike stamps (ignores sub-step precise offsets).
Weight bounds: Updated weight is clipped to
[0, Wmax]or[Wmax, 0]depending on sign.
Examples
Send a presynaptic spike with default multiplicity:
>>> sent = syn.send()
Send with custom multiplicity and receptor type:
>>> sent = syn.send(multiplicity=2.0, receptor_type=1)
- set(**kwargs)[source]#
Set NEST-style public parameters and mutable state.
Accepts keyword arguments matching NEST parameter names for this synapse model. Raises an error if
Kplusis provided (not used in this model).- Parameters:
**kwargs – Keyword arguments for parameters to update. Valid keys:
weight,delay,receptor_type,tau_plus,tau_minus,lambda,alpha,mu_plus,mu_minus,Wmax,t_lastspike.- Raises:
ValueError – If
Kplusis provided (not a valid parameter for this model).ValueError – If any provided value fails validation (e.g., negative time constant, incompatible weight/Wmax signs).
Notes
Setting
weightorWmaxwill re-validate the sign consistency constraint (both must have the same sign).