Skip to content

Built-in synapse types#

ANNarchy provides standard spiking synapse models, similar to the ones defined in PyNN (http://neuralensemble.org/docs/PyNN/reference/plasticitymodels.html).

ANNarchy.models.Synapses.Hebb #

Bases: Synapse

Rate-coded synapse with Hebbian plasticity.

Parameters (global):

  • eta = 0.01 : learning rate.

Learning rule:

  • w : weight.
dw/dt = eta * pre.r * post.r

Equivalent code:

Hebb = Synapse(
    parameters = """
        eta = 0.01 : projection
    """,
    equations = """
        dw/dt = eta * pre.r * post.r : min=0.0
    """
)
Source code in /home/docs/checkouts/readthedocs.org/user_builds/annarchy/conda/latest/lib/python3.9/site-packages/ANNarchy/models/Synapses.py
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class Hebb(Synapse):
    '''
    Rate-coded synapse with Hebbian plasticity.

    **Parameters (global)**:

    * eta = 0.01 : learning rate.

    **Learning rule**:

    * w : weight.

    ```
    dw/dt = eta * pre.r * post.r
    ```

    Equivalent code:

    ```python
    Hebb = Synapse(
        parameters = """
            eta = 0.01 : projection
        """,
        equations = """
            dw/dt = eta * pre.r * post.r : min=0.0
        """
    )
    ```

    '''
    # For reporting
    _instantiated = []

    def __init__(self, eta=0.01):

        parameters = """
            eta = %(eta)s : projection
        """ % {'eta': eta}

        equations = """
            dw/dt = eta * pre.r * post.r : min=0.0, explicit 
        """

        Synapse.__init__(self, parameters=parameters, equations=equations,
            name="Hebbian Plasticity", description="Simple Hebbian learning rule")
        # For reporting
        self._instantiated.append(True)

ANNarchy.models.Synapses.Oja #

Bases: Synapse

Rate-coded synapse with regularized Hebbian plasticity (Oja).

Parameters (global):

  • eta = 0.01 : learning rate.

  • alpha = 1.0 : regularization constant.

Learning rule:

  • w : weight:
dw/dt = eta * ( pre.r * post.r - alpha * post.r^2 * w )

Equivalent code:

Oja = Synapse(
    parameters = """
        eta = 0.01 : projection
        alpha = 1.0 : projection
    """,
    equations = """
        dw/dt = eta * ( pre.r * post.r - alpha * post.r^2 * w ) : min=0.0
    """
)
Source code in /home/docs/checkouts/readthedocs.org/user_builds/annarchy/conda/latest/lib/python3.9/site-packages/ANNarchy/models/Synapses.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
class Oja(Synapse):
    '''
    Rate-coded synapse with regularized Hebbian plasticity (Oja).

    **Parameters (global)**:

    * eta = 0.01 : learning rate.

    * alpha = 1.0 : regularization constant.

    **Learning rule**:

    * w : weight:

    ```
    dw/dt = eta * ( pre.r * post.r - alpha * post.r^2 * w )
    ```

    Equivalent code:

    ```python
    Oja = Synapse(
        parameters = """
            eta = 0.01 : projection
            alpha = 1.0 : projection
        """,
        equations = """
            dw/dt = eta * ( pre.r * post.r - alpha * post.r^2 * w ) : min=0.0
        """
    )
    ```

    '''
    # For reporting
    _instantiated = []

    def __init__(self, eta=0.01, alpha=1.0):

        parameters = """
            eta = %(eta)s : projection
            alpha = %(alpha)s : projection
        """ % {'eta': eta, 'alpha': alpha}

        equations = """
            dw/dt = eta * ( pre.r * post.r - alpha * post.r^2 * w ) : min=0.0, explicit 
        """

        Synapse.__init__(self, parameters=parameters, equations=equations,
            name="Oja plasticity", description="Regularized Hebbian learning rule.")
        # For reporting
        self._instantiated.append(True)

ANNarchy.models.Synapses.IBCM #

Bases: Synapse

Rate-coded synapse with Intrator & Cooper (1992) plasticity.

Parameters (global):

  • eta = 0.01 : learning rate.

  • tau = 2000.0 : time constant of the post-synaptic threshold.

Learning rule:

  • theta : post-synaptic threshold:
tau * dtheta/dt + theta = post.r^2
  • w : weight:
dw/dt = eta * post.r * (post.r - theta) * pre.r 

Equivalent code:

IBCM = Synapse(
    parameters = """
        eta = 0.01 : projection
        tau = 2000.0 : projection
    """,
    equations = """
        tau * dtheta/dt + theta = post.r^2 : postsynaptic, exponential
        dw/dt = eta * post.r * (post.r - theta) * pre.r : min=0.0, explicit
    """
)
Source code in /home/docs/checkouts/readthedocs.org/user_builds/annarchy/conda/latest/lib/python3.9/site-packages/ANNarchy/models/Synapses.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
class IBCM(Synapse):
    '''
    Rate-coded synapse with Intrator & Cooper (1992) plasticity.

    **Parameters (global)**:

    * eta = 0.01 : learning rate.

    * tau = 2000.0 : time constant of the post-synaptic threshold.

    **Learning rule**:

    * theta : post-synaptic threshold:

    ```
    tau * dtheta/dt + theta = post.r^2
    ```

    * w : weight:

    ```
    dw/dt = eta * post.r * (post.r - theta) * pre.r 
    ```

    Equivalent code:

    ```python
    IBCM = Synapse(
        parameters = """
            eta = 0.01 : projection
            tau = 2000.0 : projection
        """,
        equations = """
            tau * dtheta/dt + theta = post.r^2 : postsynaptic, exponential
            dw/dt = eta * post.r * (post.r - theta) * pre.r : min=0.0, explicit
        """
    )
    ```

    '''
    # For reporting
    _instantiated = []

    def __init__(self, eta = 0.01, tau = 2000.0):

        parameters = """
            eta = %(eta)s : projection
            tau = %(tau)s : projection
        """ % {'eta': eta, 'tau': tau}

        equations = """
            tau * dtheta/dt + theta = post.r^2 : postsynaptic, exponential
            dw/dt = eta * post.r * (post.r - theta) * pre.r : min=0.0, explicit
        """

        Synapse.__init__(self, parameters=parameters, equations=equations,
            name="IBCM", description="Intrator and Cooper (1992) learning rule.")
        # For reporting
        self._instantiated.append(True)

ANNarchy.models.Synapses.STP #

Bases: Synapse

Synapse exhibiting short-term facilitation and depression, implemented using the model of Tsodyks, Markram et al.:

Tsodyks, Uziel and Markram (2000) Synchrony Generation in Recurrent Networks with Frequency-Dependent Synapses. Journal of Neuroscience 20:RC50

Note that the time constant of the post-synaptic current is set in the neuron model, not here.

Parameters (global):

  • tau_rec = 100.0 : depression time constant (ms).
  • tau_facil = 0.01 : facilitation time constant (ms).
  • U = 0.5 : use parameter.

Variables:

  • x : recovery variable::
dx/dt = (1 - x)/tau_rec 
  • u : facilitation variable::
du/dt = (U - u)/tau_facil 

Both variables are integrated event-driven.

Pre-spike events:

g_target += w * u * x
x *= (1 - u)
u += U * (1 - u)

Equivalent code:

STP = Synapse(
    parameters = """
        tau_rec = 100.0 : projection
        tau_facil = 0.01 : projection
        U = 0.5
    """,
    equations = """
        dx/dt = (1 - x)/tau_rec : init = 1.0, event-driven
        du/dt = (U - u)/tau_facil : init = 0.5, event-driven
    """,
    pre_spike="""
        g_target += w * u * x
        x *= (1 - u)
        u += U * (1 - u)
    """
)
Source code in /home/docs/checkouts/readthedocs.org/user_builds/annarchy/conda/latest/lib/python3.9/site-packages/ANNarchy/models/Synapses.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
class STP(Synapse):
    '''
    Synapse exhibiting short-term facilitation and depression, implemented using the model of Tsodyks, Markram et al.:

    Tsodyks, Uziel and Markram (2000) Synchrony Generation in Recurrent Networks with Frequency-Dependent Synapses. Journal of Neuroscience 20:RC50

    Note that the time constant of the post-synaptic current is set in the neuron model, not here.

    **Parameters (global)**:

    * tau_rec = 100.0 : depression time constant (ms).
    * tau_facil = 0.01 : facilitation time constant (ms).
    * U = 0.5 : use parameter.

    **Variables**:

    * x : recovery variable::

    ```
    dx/dt = (1 - x)/tau_rec 
    ```

    * u : facilitation variable::

    ```
    du/dt = (U - u)/tau_facil 
    ```

    Both variables are integrated event-driven. 

    **Pre-spike events**:

    ```
    g_target += w * u * x
    x *= (1 - u)
    u += U * (1 - u)
    ```

    Equivalent code:

    ```python
    STP = Synapse(
        parameters = """
            tau_rec = 100.0 : projection
            tau_facil = 0.01 : projection
            U = 0.5
        """,
        equations = """
            dx/dt = (1 - x)/tau_rec : init = 1.0, event-driven
            du/dt = (U - u)/tau_facil : init = 0.5, event-driven
        """,
        pre_spike="""
            g_target += w * u * x
            x *= (1 - u)
            u += U * (1 - u)
        """
    )
    ```

    '''
    # For reporting
    _instantiated = []

    def __init__(self, tau_rec=100.0, tau_facil=0.01, U=0.5):

        if tau_facil<= 0.0:
            _error('STP: tau_facil must be positive. Choose a very small value if you have to, or derive a new synapse.')

        parameters = """
            tau_rec = %(tau_rec)s : projection
            tau_facil = %(tau_facil)s : projection
            U = %(U)s
        """ % {'tau_rec': tau_rec, 'tau_facil': tau_facil, 'U': U}
        equations = """
            dx/dt = (1 - x)/tau_rec : init = 1.0, event-driven
            du/dt = (U - u)/tau_facil : init = %(U)s, event-driven   
        """ % {'tau_rec': tau_rec, 'tau_facil': tau_facil, 'U': U}
        pre_spike="""
            g_target += w * u * x
            x *= (1 - u)
            u += U * (1 - u)
        """

        Synapse.__init__(self, parameters=parameters, equations=equations, pre_spike=pre_spike,
            name="Short-term plasticity", description="Synapse exhibiting short-term facilitation and depression, implemented using the model of Tsodyks, Markram et al.")
        # For reporting
        self._instantiated.append(True)

ANNarchy.models.Synapses.STDP #

Bases: Synapse

Spike-timing dependent plasticity.

This is the online version of the STDP rule.

Song, S., and Abbott, L.F. (2001). Cortical development and remapping through spike timing-dependent plasticity. Neuron 32, 339-350.

Parameters (global):

  • tau_plus = 20.0 : time constant of the pre-synaptic trace (ms)
  • tau_minus = 20.0 : time constant of the pre-synaptic trace (ms)
  • A_plus = 0.01 : increase of the pre-synaptic trace after a spike.
  • A_minus = 0.01 : decrease of the post-synaptic trace after a spike.
  • w_min = 0.0 : minimal value of the weight w.
  • w_max = 1.0 : maximal value of the weight w.

Variables:

  • x : pre-synaptic trace:
tau_plus  * dx/dt = -x
  • y: post-synaptic trace:
tau_minus * dy/dt = -y

Both variables are evaluated event-driven.

Pre-spike events:

g_target += w

x += A_plus * w_max

w = clip(w + y, w_min , w_max)

Post-spike events::

y -= A_minus * w_max

w = clip(w + x, w_min , w_max)

Equivalent code:

STDP = Synapse(
    parameters = """
        tau_plus = 20.0 : projection
        tau_minus = 20.0 : projection
        A_plus = 0.01 : projection
        A_minus = 0.01 : projection
        w_min = 0.0 : projection
        w_max = 1.0 : projection
    """,
    equations = """
        tau_plus  * dx/dt = -x : event-driven
        tau_minus * dy/dt = -y : event-driven
    """,
    pre_spike="""
        g_target += w
        x += A_plus * w_max
        w = clip(w + y, w_min , w_max)
    """,
    post_spike="""
        y -= A_minus * w_max
        w = clip(w + x, w_min , w_max)
    """
)
Source code in /home/docs/checkouts/readthedocs.org/user_builds/annarchy/conda/latest/lib/python3.9/site-packages/ANNarchy/models/Synapses.py
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
class STDP(Synapse):
    '''
    Spike-timing dependent plasticity.

    This is the online version of the STDP rule.

    Song, S., and Abbott, L.F. (2001). Cortical development and remapping through spike timing-dependent plasticity. Neuron 32, 339-350. 

    **Parameters (global)**:

    * tau_plus = 20.0 : time constant of the pre-synaptic trace (ms)
    * tau_minus = 20.0 : time constant of the pre-synaptic trace (ms)
    * A_plus = 0.01 : increase of the pre-synaptic trace after a spike.
    * A_minus = 0.01 : decrease of the post-synaptic trace after a spike. 
    * w_min = 0.0 : minimal value of the weight w.
    * w_max = 1.0 : maximal value of the weight w.

    **Variables**:

    * x : pre-synaptic trace:

    ```
    tau_plus  * dx/dt = -x
    ```

    * y: post-synaptic trace:

    ```
    tau_minus * dy/dt = -y
    ```

    Both variables are evaluated event-driven.

    **Pre-spike events**:

    ```
    g_target += w

    x += A_plus * w_max

    w = clip(w + y, w_min , w_max)
    ```

    **Post-spike events**::

    ```
    y -= A_minus * w_max

    w = clip(w + x, w_min , w_max)
    ```

    Equivalent code:

    ```python

    STDP = Synapse(
        parameters = """
            tau_plus = 20.0 : projection
            tau_minus = 20.0 : projection
            A_plus = 0.01 : projection
            A_minus = 0.01 : projection
            w_min = 0.0 : projection
            w_max = 1.0 : projection
        """,
        equations = """
            tau_plus  * dx/dt = -x : event-driven
            tau_minus * dy/dt = -y : event-driven
        """,
        pre_spike="""
            g_target += w
            x += A_plus * w_max
            w = clip(w + y, w_min , w_max)
        """,
        post_spike="""
            y -= A_minus * w_max
            w = clip(w + x, w_min , w_max)
        """
    )
    ```

    '''
    # For reporting
    _instantiated = []

    def __init__(self, tau_plus=20.0, tau_minus=20.0, A_plus=0.01, A_minus=0.01, w_min=0.0, w_max=1.0):

        parameters="""
            tau_plus = %(tau_plus)s : projection
            tau_minus = %(tau_minus)s : projection
            A_plus = %(A_plus)s : projection
            A_minus = %(A_minus)s : projection
            w_min = %(w_min)s : projection
            w_max = %(w_max)s : projection
        """ % {'tau_plus': tau_plus, 'tau_minus':tau_minus, 'A_plus':A_plus, 'A_minus': A_minus, 'w_min': w_min, 'w_max': w_max}

        equations = """
            tau_plus  * dx/dt = -x : event-driven
            tau_minus * dy/dt = -y : event-driven
        """
        pre_spike="""
            g_target += w
            x += A_plus * w_max
            w = clip(w + y, w_min , w_max)
        """          
        post_spike="""
            y -= A_minus * w_max
            w = clip(w + x, w_min , w_max)
        """

        Synapse.__init__(self, parameters=parameters, equations=equations, pre_spike=pre_spike, post_spike=post_spike,
            name="Spike-timing dependent plasticity", description="Synapse exhibiting spike-timing dependent plasticity.")
        # For reporting
        self._instantiated.append(True)