File: examples-twister_FriedemannZenke.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (137 lines) | stat: -rw-r--r-- 4,292 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; NeuronGroup
   pair: example usage; run
   pair: example usage; xlim
   pair: example usage; title
   pair: example usage; raster_plot
   pair: example usage; show
   pair: example usage; Connection
   pair: example usage; xlabel
   pair: example usage; SpikeMonitor
   pair: example usage; STDP

.. _example-twister_FriedemannZenke:

Example: FriedemannZenke (twister)
==================================

Friedemann Zenke's winning entry for the 2012 Brian twister.

::

    # ###########################################
    #
    # Inhibitory synaptic plasticity in a recurrent network model 
    # (F. Zenke, 2011)
    #
    # Adapted from: 
    # Vogels, T. P., H. Sprekeler, F. Zenke, C. Clopath, and W. Gerstner. 
    # 'Inhibitory Plasticity Balances Excitation and Inhibition in Sensory
    # Pathways and Memory Networks.' Science (November 10, 2011). 
    #
    # ###########################################
    
    from brian import *
    
    # ###########################################
    # Defining network model parameters
    # ###########################################
    
    NE = 8000          # Number of excitatory cells
    NI = NE/4          # Number of inhibitory cells 
    
    w = 1.*nS           # Basic weight unit
    tau_ampa = 5.0*ms   # Glutamatergic synaptic time constant
    tau_gaba = 10.0*ms  # GABAergic synaptic time constant
    epsilon = 0.02      # Sparseness of synaptic connections
    
    eta = 1e-2          # Learning rate
    tau_stdp = 20*ms    # STDP time constant
    
    simtime = 10*second # Simulation time
    
    # ###########################################
    # Neuron model
    # ###########################################
    
    gl = 10.0*nsiemens   # Leak conductance
    el = -60*mV          # Resting potential
    er = -80*mV          # Inhibitory reversal potential
    vt = -50.*mV         # Spiking threshold
    memc = 200.0*pfarad  # Membrane capacitance
    bgcurrent = 200*pA   # External current
    
    eqs_neurons='''
    dv/dt=(-gl*(v-el)-(g_ampa*w*v+g_gaba*(v-er)*w)+bgcurrent)/memc : volt
    dg_ampa/dt = -g_ampa/tau_ampa : 1
    dg_gaba/dt = -g_gaba/tau_gaba : 1
    '''
    
    # ###########################################
    # Initialize neuron group
    # ###########################################
    
    neurons=NeuronGroup(NE+NI,model=eqs_neurons,threshold=vt,reset=el,refractory=5*ms)
    Pe=neurons.subgroup(NE)
    Pi=neurons.subgroup(NI)
    
    # ###########################################
    # Connecting the network 
    # ###########################################
    
    con_e = Connection(Pe,neurons,'g_ampa',weight=0.3,sparseness=epsilon)
    con_ie = Connection(Pi,Pe,'g_gaba',weight=1e-10,sparseness=epsilon)
    con_ii = Connection(Pi,Pi,'g_gaba',weight=3,sparseness=epsilon)
    
    # ###########################################
    # Setting up monitors
    # ###########################################
    
    sm = SpikeMonitor(Pe)
    
    # ###########################################
    # Run without plasticity
    # ###########################################
    
    run(1*second)
    
    # ###########################################
    # Inhibitory Plasticity
    # ###########################################
    
    alpha = 3*Hz*tau_stdp*2  # Target rate parameter
    gmax = 100               # Maximum inhibitory weight
    
    eqs_stdp_inhib = '''
    dA_pre/dt=-A_pre/tau_stdp : 1
    dA_post/dt=-A_post/tau_stdp : 1
    '''
    
    stdp_ie = STDP(con_ie, eqs=eqs_stdp_inhib, pre='A_pre+=1.; w+=(A_post-alpha)*eta;',
            post='A_post+=1.; w+=A_pre*eta;', wmax=gmax)
    
    # ###########################################
    # Run with plasticity
    # ###########################################
    
    run(simtime-1*second,report='text')
    
    # ###########################################
    # Make plots
    # ###########################################
    
    subplot(211)
    raster_plot(sm,ms=1.)
    title("Before")
    xlabel("")
    xlim(float(0.8*second/ms), float(1*second/ms))
    subplot(212)
    raster_plot(sm,ms=1.)
    title("After")
    xlim(float((simtime-0.2*second)/ms), float(simtime/ms))
    show()