-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbi_poo.py
150 lines (115 loc) · 4.42 KB
/
bi_poo.py
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
138
139
140
141
142
143
144
145
146
147
148
149
150
"""
Here we reproduce experiments reported in
"Synaptic Modifications in Cultured Hippocampal Neurons:
Dependence on Spike Timing, Synaptic Strength, and
Postsynaptic Cell Type"
Guo-qiang Bi and Mu-ming Poo
The Journal of Neuroscience, 1998
Specifically, we investigate the basic spike-timing dependence of plasticity
by manipulating the relative difference of pre- and postsynaptic spikes
(Figure 7). The data from this figure can be found in
the "experimental_data" folder.
Approximate runtime on an Intel Xeon X3470 machine (4 CPUs, 8 threads):
< 2min
Running this file should produce 101 .p files.
Afterwards, code in the corresponding
IPython notebook will produce a figure showing experimental data and
simulation results next to each other.
"""
from util import get_all_save_keys, get_periodic_current, get_inst_backprop, get_phi_spiker, get_dendr_spike_det, get_fixed_spiker
from helper import do, PeriodicAccumulator, BooleanAccumulator, dump, get_default
import numpy as np
from IPython import embed
import cPickle
from collections import OrderedDict
from simulation import run
import matplotlib.pyplot as plt
import time
import os
def fit((repetition_i,p)):
values = {True: {"alpha":-55.0,
"beta":0.4,
"r_max":0.3},
False: {"alpha":-59.0,
"beta":0.5,
"r_max":0.17}}
neuron = get_default("neuron")
neuron["phi"]['r_max'] = values[p["h1"]]["r_max"]
neuron["phi"]['alpha'] = values[p["h1"]]["alpha"]
neuron["phi"]['beta'] = values[p["h1"]]["beta"]
learn = get_default("learn")
if not p["h1"]:
learn["eta"] = learn["eta"]*2.5
else:
learn["eta"] = learn["eta"]*1.3
spikes = np.array([101.0])
my_s = {
'start': 0.0,
'end': 300.0,
'dt': 0.05,
'pre_spikes': [spikes + p["delta"]],
'I_ext': lambda t: 0.0
}
seed = 1
accs = [PeriodicAccumulator(['y','weights'], interval=10), BooleanAccumulator(['spike', 'dendr_spike', 'pre_spikes'])]
if p["h1"]:
accums = run(my_s, get_fixed_spiker(spikes), get_dendr_spike_det(-50.0), accs, seed=seed, neuron=neuron, learn=learn, h=1.0)
else:
accums = run(my_s, get_fixed_spiker(spikes), get_dendr_spike_det(-50.0), accs, seed=seed, neuron=neuron, learn=learn)
dump((accums, values),'bi_poo/'+p['ident'])
params = OrderedDict()
params["h1"] = [False, True]
params["delta"] = np.linspace(-100.0, 100.0, 101)
file_prefix = 'bi_poo_fit'
do(fit, params, file_prefix, create_notebooks=False)
def vary((repetition_i,p)):
n_vary = 5
values = {True: {"alpha":-55.0,
"beta":0.4,
"r_max":0.3},
False: {"alpha":-59.0,
"beta":0.5,
"r_max":0.17}}
vary = {"alpha":(-2.0,2.0),
"beta":(-0.1,0.2),
"r_max":(-0.05,0.15)}
down = vary[p["vary"]][0]
up = vary[p["vary"]][1]
middle = values[p["h1"]][p["vary"]]
vary_val = np.linspace(middle+down, middle+up, n_vary)[p["i"]]
values[p["h1"]][p["vary"]] = vary_val
values = values[p["h1"]]
neuron = get_default("neuron")
neuron["phi"]['r_max'] = values["r_max"]
neuron["phi"]['alpha'] = values["alpha"]
neuron["phi"]['beta'] = values["beta"]
learn = get_default("learn")
learn["eps"] = learn["eps"]*p["l_f"]
learn["eta"] = learn["eta"]*p["l_f"]
if not p["h1"]:
learn["eta"] = learn["eta"]*2.5
else:
learn["eta"] = learn["eta"]*1.3
spikes = np.array([61.0])
my_s = {
'start': 0.0,
'end': 150.0,
'dt': 0.05,
'pre_spikes': [spikes + p["delta"]],
'I_ext': lambda t: 0.0
}
seed = 1
accs = [PeriodicAccumulator(['y','weights'], interval=10), BooleanAccumulator(['spike', 'dendr_spike', 'pre_spikes'])]
if p["h1"]:
accums = run(my_s, get_fixed_spiker(spikes), get_dendr_spike_det(-50.0), accs, seed=seed, neuron=neuron, learn=learn, h=1.0)
else:
accums = run(my_s, get_fixed_spiker(spikes), get_dendr_spike_det(-50.0), accs, seed=seed, neuron=neuron, learn=learn)
dump((accums, values),'bi_poo/'+p['ident'])
params = OrderedDict()
params["vary"] = ["alpha", "beta", "r_max"]
params["h1"] = [False, True]
params["l_f"] = [1.0,10.0]
params["delta"] = np.linspace(-60.0, 60.0, 31)
params["i"] = range(5)
file_prefix = 'bi_poo_vary'
do(vary, params, file_prefix, create_notebooks=False)