# STDP on both inhibitory and excitatory synapses?

**URL:** <https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605>\
**Category:** Support\
**Created:** [8 February 2022 17:13 UTC](https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605 "2022-02-08T17:13:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rihana](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/rihana/32/369_2.png) [@Rihana](https://brian.discourse.group/u/Rihana)\
**Post date:** [8 February 2022 17:13 UTC](https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605/1 "2022-02-08T17:13:53Z")

</div>

Hi all,  
I’m trying to implement a network containing both excitatory and inhibitory neurons( 80%-20%) whose weights are changing with STDP rule.  
I have 2 types of synapses defined as follows:

> inh\_syn = Synapses(inh\_neurons, neurons, model=synapses\_eqs,  
> on\_pre=stdp\_pre,on\_post=stdp\_post’)

> exc\_syn = Synapses(exc\_neurons, neurons, model=synapses\_eqs,  
> on\_pre=stdp\_pre, on\_post=stdp\_post)

My ambiguity is that do I use similar stdp\_pre and stdp\_post for both type of synapses ? I mean

> #excitatory  
> stdp\_pre=‘’‘g\_e\_post += w\_e  
> Apre += dApre  
> w\_e\_t = clip(w\_e + Apost, 0, gmax)’‘’  
> stdp\_post=‘’‘Apost += dApost  
> w\_e= clip(w\_e + Apre,0, gmax)’‘’  
> #inhibitory  
> stdp\_pre=‘’‘g\_i\_post += w\_i  
> Apre += dApre  
> w\_i = clip(w\_i + Apost, 0, gmax)’‘’  
> stdp\_post=‘’‘Apost += dApost  
> w\_i= clip(w\_i + Apre,0, gmax)’‘’

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [9 February 2022 09:57 UTC](https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605/2 "2022-02-09T09:57:55Z")

</div>

Hi @Rihana . If you want to use the same learning rule, then indeed you’d use very similar `on_pre` and `on_post` statements for both, as in your example. If you want to repeat yourself a bit less, you could call the synaptic weights `w` in both cases, and then construct your `on_pre`/`on_post` statements like this:

```auto
stdp_pre = '''
Apre += dApre
w = clip(w + Apost, 0, gmax)'''
stdp_post = '''Apost += dApost
w= clip(w + Apre,0, gmax)'''
inh_syn = Synapses(inh_neurons, neurons, model=synapses_eqs,
                   on_pre='g_i_post += w' + stdp_pre, on_post=stdp_post)
exc_syn = Synapses(exc_neurons, neurons, model=synapses_eqs,
                   on_pre='g_e_post += w' + stdp_pre, on_post=stdp_post)

```

---

<div class="post-metadata">

**Author:** ![Rihana](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/rihana/32/369_2.png) [@Rihana](https://brian.discourse.group/u/Rihana)\
**Post date:** [10 February 2022 19:53 UTC](https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605/3 "2022-02-10T19:53:19Z")

</div>

Thanks very much for you reply.  
That was for expressing my meaning of question.  
As I’ve mentioned, my question is when I have 2 types of synapses, how STDP defines on them.  
In Brian2 sample for STDP, it is for excitatory ones in a network containing only excitatory synapses not both simultaneously.

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [14 February 2022 17:36 UTC](https://brian.discourse.group/t/stdp-on-both-inhibitory-and-excitatory-synapses/605/4 "2022-02-14T17:36:07Z")

</div>

Hi @Rihana. I’m afraid I am still having trouble understanding your question. You can add STDP equations for excitatory or inhibitory synapses, whether these synapses are excitatory or inhibitory does not make a difference from Brian’s point of view (from empirical observations or theoretical considerations, you might consider different rules for excitatory and inhibitory synapses, but this is up to you). In the basic Brian 2 STDP example, there are only excitatory synapses. But, e.g. in the [example implementing Vogels et al. (2011)](https://brian2.readthedocs.io/en/stable/examples/frompapers.Vogels_et_al_2011.html), there are excitatory and inhibitory synapses, but only the inhibitory synapses are plastic.
