-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathargparser.py
382 lines (301 loc) · 15.1 KB
/
argparser.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
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
232
233
234
235
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
323
324
325
326
327
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
import argparse
# Current defaults for [App: Motion detection]
# as of 5.09.2018
# Previous version:
# topographic map formation B.O.T -> 30.07.2018
# Constants
CASE_CORR_AND_REW = 1
CASE_CORR_NO_REW = 2
CASE_REW_NO_CORR = 3
SSP = 1
SSA = 2
DEFAULT_TAU_REFRAC = 5.0
DEFAULT_TAU_SYN_I = 5.0
DEFAULT_F_PEAK = 152.8
DEFAULT_F_BASE = 5
DEFAULT_NO_ITERATIONS = 2400000
DEFAULT_TESTING_ITERATIONS = 1200000
DEFAULT_T_RECORD = 100000
DEFAULT_T_STIM = 20
DEFAULT_S_MAX = 96
DEFAULT_F_MEAN = 20
DEFAULT_F_REW = 10 ** 4
DEFAULT_LAT_INH = False
DEFAULT_G_MAX = 0.2
DEFAULT_N = 32
DEFAULT_DELAY = 1
DEFAULT_SPIKE_SOURCE = SSP
DEFAULT_B = 1.2
DEFAULT_T_MINUS = 64
DEFAULT_SIGMA_STIM = 2
DEFAULT_SIGMA_FORM_LAT = 5
DEFAULT_SIGMA_FORM_FF = 5
# Default probabilities
DEFAULT_P_FORM_LATERAL = 1
DEFAULT_P_FORM_FORWARD = 0.16
DEFAULT_P_ELIM_DEP = 0.0245
DEFAULT_P_ELIM_POT = 1.36 * (10 ** -4)
# Different input types
GAUSSIAN_INPUT = 1
POINTY_INPUT = 2
SCALED_POINTY_INPUT = 3
SQUARE_INPUT = 4
# Types of lesions / insult / developmental starting conditions
NO_LESION = 0
RANDOM_CONNECTIVITY_LESION = 1
ONE_TO_ONE_LESION = 2
# Enable latero-lateral interaction
DEFAULT_LAT_LAT_CONN = False
# Topology configuration
DEFAULT_TOPOLOGY = 3
DEFAULT_DELAY_TYPE = True
DEFAULT_FPS = 200
DEFAULT_CHUNK_SIZE = 200 # ms
DEFAULT_JITTER = False
DEFAULT_COPLANAR_UPPER_DELAY = 3 # ms, exclusive
DEFAULT_FIXED_SIGNAL = None
DEFAULT_FIXED_SIGNAL_VALUE = 20 # Hz
parser = argparse.ArgumentParser(
description='Test for topographic map formation using STDP and '
'synaptic rewiring on SpiNNaker.',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-c", '--case', type=int,
choices=[CASE_CORR_AND_REW, CASE_CORR_NO_REW,
CASE_REW_NO_CORR],
default=CASE_CORR_AND_REW, dest='case',
help='an integer controlling the experimental setup'
' -- [default {}]'.format(CASE_CORR_AND_REW))
parser.add_argument('--testing', type=str, dest='testing',
help='put the network in testing mode. provide .npz'
'archive with connectivity information to commence'
'testing')
parser.add_argument('--expands', type=str,
help='defines the network connectivity starting point as '
'the end point of a different training simulation')
parser.add_argument("-l", '--lesion', type=int,
choices=[NO_LESION, RANDOM_CONNECTIVITY_LESION,
ONE_TO_ONE_LESION],
default=NO_LESION, dest='lesion',
help='what type of lesion to do (none, random, 1:1, '
'all:all)'
' -- [default {}]'.format(NO_LESION))
parser.add_argument('--p_elim_dep', type=float,
default=DEFAULT_P_ELIM_DEP, dest='p_elim_dep',
help='probability of eliminating depressed synapses'
' -- [default {}]'.format(DEFAULT_P_ELIM_DEP))
parser.add_argument('--fixed_signal_value', type=float,
default=DEFAULT_FIXED_SIGNAL_VALUE,
help='[App: MNIST] mnist signal has fixed value'
' -- [default {} Hz]'.format(DEFAULT_FIXED_SIGNAL_VALUE))
parser.add_argument('--fixed_signal', action="store_true",
help='[App: MNIST] enable fixed signal rather than mean firing'
' -- [default {}]'.format(DEFAULT_FIXED_SIGNAL))
parser.add_argument('--chunk', type=int,
default=None, dest='chunk_size',
help='length of presentation of a pattern (in ms)'
' -- [default {}]'.format(DEFAULT_CHUNK_SIZE))
parser.add_argument('--g_max', type=float,
default=DEFAULT_G_MAX, dest='g_max',
help='Maximum synaptic weight'
' -- [default {}]'.format(DEFAULT_G_MAX))
parser.add_argument('--p_elim_pot', type=float,
default=DEFAULT_P_ELIM_POT, dest='p_elim_pot',
help='probability of eliminating potentiated synapses'
' -- [default {}]'.format(DEFAULT_P_ELIM_POT))
parser.add_argument('--p_form_forward', type=float,
default=DEFAULT_P_FORM_FORWARD, dest='p_form_forward',
help='probability of forming feedforward synapses'
' -- [default {}]'.format(DEFAULT_P_FORM_FORWARD))
parser.add_argument('--p_form_lateral', type=float,
default=DEFAULT_P_FORM_LATERAL, dest='p_form_lateral',
help='probability of forming lateral synapses'
' -- [default {}]'.format(DEFAULT_P_FORM_LATERAL))
parser.add_argument('--tau_refract', type=float,
default=DEFAULT_TAU_REFRAC, dest='tau_refrac',
help='refractory time constant (ms)'
' -- [default {}]'.format(DEFAULT_TAU_REFRAC))
parser.add_argument('--tau_syn_i', type=float,
default=DEFAULT_TAU_SYN_I, dest='tau_syn_i',
help='inhibitory current time constant (ms)'
' -- [default {}]'.format(DEFAULT_TAU_SYN_I))
parser.add_argument('--sigma_stim', type=float,
default=DEFAULT_SIGMA_STIM, dest='sigma_stim',
help='[App: Topographic map formation] stimulus spread'
' -- [default {}]'.format(DEFAULT_SIGMA_STIM))
parser.add_argument('--sigma_form_lat', type=float,
default=DEFAULT_SIGMA_FORM_LAT, dest='sigma_form_lat',
help='spread of lateral formations'
' -- [default {}]'.format(DEFAULT_SIGMA_FORM_LAT))
parser.add_argument('--sigma_form_ff', type=float,
default=DEFAULT_SIGMA_FORM_FF, dest='sigma_form_ff',
help='spread of feedforward formations'
' -- [default {}]'.format(DEFAULT_SIGMA_FORM_FF))
parser.add_argument('-n', '--n', type=int,
default=DEFAULT_N, dest='n',
help='size of one edge of the layer'
' -- [default {}]'.format(DEFAULT_N))
parser.add_argument('--t_record', type=int,
default=DEFAULT_T_RECORD, dest='t_record',
help='time between retrieval of recordings (ms)'
' -- [default {}]'.format(DEFAULT_T_RECORD))
parser.add_argument('--lat_inh', action="store_true",
dest='lateral_inhibition',
help='enable lateral inhibition'
' -- [default {}]'.format(DEFAULT_LAT_INH))
parser.add_argument('--t_stim', type=int,
default=DEFAULT_T_STIM, dest='t_stim',
help='time between stimulus location change (ms)')
parser.add_argument('--f_peak', type=float,
default=DEFAULT_F_PEAK, dest='f_peak',
help='peak input spike rate (Hz)')
parser.add_argument('--f_base', type=float,
default=DEFAULT_F_BASE, dest='f_base',
help='base input spike rate (Hz)')
parser.add_argument('--f_rew', type=float,
default=DEFAULT_F_REW, dest='f_rew',
help='frequency of rewire attempts (Hz)')
parser.add_argument('--f_mean', type=float,
default=DEFAULT_F_MEAN, dest='f_mean',
help='input spike rate (Hz) used with case 3')
parser.add_argument('--s_max', type=int,
default=DEFAULT_S_MAX, dest='s_max',
help='maximum synaptic capacity'
' -- [default {}]'.format(DEFAULT_S_MAX))
parser.add_argument('--b', type=float,
default=DEFAULT_B, dest='b',
help='ration between area under depression curve and '
'area under potentiation curve'
' -- [default {}]'.format(DEFAULT_B))
parser.add_argument('--t_minus', type=int,
default=DEFAULT_T_MINUS, dest='t_minus',
help='time constant for depression'
' -- [default {}]'.format(DEFAULT_T_MINUS))
parser.add_argument('--delay', type=int,
default=DEFAULT_DELAY,
help='delay_distribution (in ms) applied to '
'spikes in the network')
parser.add_argument('--no_iterations', type=int,
default=DEFAULT_NO_ITERATIONS, dest='no_iterations',
help='total number of iterations (or time steps) for '
'the simulation (technically, ms)'
' -- [default {}]'.format(DEFAULT_NO_ITERATIONS))
parser.add_argument('--testing_iterations', type=int,
default=DEFAULT_TESTING_ITERATIONS,
dest='testing_iterations',
help='total number of testing iterations (or time steps) '
'for '
'the simulation (technically, ms)'
' -- [default {}]'.format(DEFAULT_TESTING_ITERATIONS))
parser.add_argument('--plot', help="display plots",
action="store_true")
parser.add_argument('--record_source',
help="record spikes generated by the source layer",
action="store_true")
parser.add_argument('--record_exc_v',
help="record voltage for the excitatory layer",
action="store_true")
parser.add_argument('--random_partner',
help="select a random partner for rewiring rather than "
"the last neuron to have spiked",
action="store_true")
parser.add_argument('-o', '--output', type=str,
help="name of the numpy archive "
"storing simulation results",
dest='filename')
parser.add_argument('-i', '--input', type=str,
help="name of the numpy archive storing "
"initial connectivity for the simulation",
dest='initial_connectivity_file')
parser.add_argument('--input_type', type=int,
choices=[GAUSSIAN_INPUT, POINTY_INPUT,
SCALED_POINTY_INPUT, SQUARE_INPUT],
default=GAUSSIAN_INPUT, dest='input_type',
help='[App: Topographic map formation] what type of '
'input shape to use (gaussian, pointy, '
'scaled pointy, square)'
' -- [default {}]'.format(GAUSSIAN_INPUT))
parser.add_argument('--random_input',
help="instead of input a digit"
" input noise at prescribed f_mean",
action="store_true")
parser.add_argument('--no_lateral_conn',
help="[App: MNIST] run experiment without "
"lateral "
"connectivity",
action="store_true")
parser.add_argument('--constant_delay',
help="[App: Motion detection] constant delay_distribution",
action="store_true")
parser.add_argument('--lat_lat_conn',
help="run experiment with latero-lateral "
"connectivity", default=DEFAULT_LAT_LAT_CONN,
action="store_true")
parser.add_argument('--topology',
help="[App: Motion detection] Modifies the "
"architecture of the network (0. constant lateral "
"inhibition, 1. no lateral inhibition, "
"2. learned lateral inhibition, 3. lat inh now also "
"sees the input)"
" -- [default {}]".format(DEFAULT_TOPOLOGY),
type=int, default=DEFAULT_TOPOLOGY,
choices=[0, 1, 2, 3],
dest='topology')
parser.add_argument('-ta', '--training_angles',
help="[App: Motion detection] Network will be trained "
"using a random succession of these angles"
" -- [default {}]".format([0]),
type=int, nargs="+", default=[0],
dest='training_angles'
)
parser.add_argument('--all_angles',
help="[App: Motion detection] Network will be trained "
"using a random succession of all angles",
action="store_true",
dest='all_angles'
)
parser.add_argument('--fps',
help="[App: Motion detection] Bar speed across "
"receptive field (default is 200)",
type=int, default=DEFAULT_FPS,
dest='fps')
parser.add_argument('--record_inh',
help="record spikes generated by the inhibitory layer",
action="store_false")
parser.add_argument('--jitter',
help="[App: Motion detection] jitter the input by +-1 ms",
action="store_true")
parser.add_argument('--common_rewiring_seed',
help="[App: Motion detection] common rewiring shared "
"seed means post neurons are selected in tandem",
action="store_true")
# flag to force simulation re-run
parser.add_argument('--no-cache',
help="force simulation re-run without "
"using cached "
"information"
" -- [default {}]".format(False),
action="store_true", dest="no_cache")
parser.add_argument('--fsi',
help="inhibitory cells have dynamics akin to Fast Spiking Interneurons (FSI)"
" -- [default {}]".format(False),
action="store_true", dest="fsi")
# f_rew exc + inh needed to see if behaviour of populations matches observations in Nowke2018
parser.add_argument('--f_rew_exc',
help="[App: Motion detection] Rate of rewiring (Hz) attempts for the EXC population",
type=float, default=DEFAULT_F_REW)
parser.add_argument('--f_rew_inh',
help="[App: Motion detection] Rate of rewiring (Hz) attempts for the INH population",
type=float, default=DEFAULT_F_REW)
parser.add_argument('--no_off_polarity', help="disable off polarity for moving bar",
action="store_true")
parser.add_argument('--stationary_input', help="disable off polarity for moving bar",
action="store_true")
parser.add_argument('--mnist_input', help="input MNIST, not moving bars",
action="store_true")
parser.add_argument('--coplanar',
help="Target layers are now coplanar. Affects delay between them"
" -- [default {}]".format(None),
type=int, default=None)
parser.add_argument('--invert_polarities', help="flip polarities for moving bar",
action="store_true")
args = parser.parse_args()