You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"The convenient simulation interfaces for dynamical systems in BrainPy are implemented in ``brainpy.simulation.runner``. Currently, we implement two kinds of runner: ``DSRunner`` and ``ReportRunner``. They have their respective advantages. "
34
50
]
@@ -37,7 +53,11 @@
37
53
"cell_type": "code",
38
54
"execution_count": 41,
39
55
"id": "c79f1bb6",
40
-
"metadata": {},
56
+
"metadata": {
57
+
"pycharm": {
58
+
"name": "#%%\n"
59
+
}
60
+
},
41
61
"outputs": [],
42
62
"source": [
43
63
"import brainpy as bp\n",
@@ -49,15 +69,23 @@
49
69
{
50
70
"cell_type": "markdown",
51
71
"id": "8addcec8",
52
-
"metadata": {},
72
+
"metadata": {
73
+
"pycharm": {
74
+
"name": "#%% md\n"
75
+
}
76
+
},
53
77
"source": [
54
78
"## Initializing a runner"
55
79
]
56
80
},
57
81
{
58
82
"cell_type": "markdown",
59
83
"id": "a9e04882",
60
-
"metadata": {},
84
+
"metadata": {
85
+
"pycharm": {
86
+
"name": "#%% md\n"
87
+
}
88
+
},
61
89
"source": [
62
90
"Generally, we can initialize a runner with the format of:\n",
63
91
"\n",
@@ -73,7 +101,11 @@
73
101
{
74
102
"cell_type": "markdown",
75
103
"id": "1a4205d5",
76
-
"metadata": {},
104
+
"metadata": {
105
+
"pycharm": {
106
+
"name": "#%% md\n"
107
+
}
108
+
},
77
109
"source": [
78
110
"In which\n",
79
111
"- ``target`` specifies the model to be simulated. It must an instance of [brainpy.DynamicalSystem](../apis/auto/simulation/generated/brainpy.simulation.brainobjects.DynamicalSystem.rst). \n",
@@ -86,7 +118,11 @@
86
118
{
87
119
"cell_type": "markdown",
88
120
"id": "94806315",
89
-
"metadata": {},
121
+
"metadata": {
122
+
"pycharm": {
123
+
"name": "#%% md\n"
124
+
}
125
+
},
90
126
"source": [
91
127
"Here we define an E/I balanced network as the simulation model. "
92
128
]
@@ -95,7 +131,11 @@
95
131
"cell_type": "code",
96
132
"execution_count": 42,
97
133
"id": "06017318",
98
-
"metadata": {},
134
+
"metadata": {
135
+
"pycharm": {
136
+
"name": "#%%\n"
137
+
}
138
+
},
99
139
"outputs": [],
100
140
"source": [
101
141
"class EINet(bp.Network):\n",
@@ -123,23 +163,35 @@
123
163
{
124
164
"cell_type": "markdown",
125
165
"id": "f00418dd",
126
-
"metadata": {},
166
+
"metadata": {
167
+
"pycharm": {
168
+
"name": "#%% md\n"
169
+
}
170
+
},
127
171
"source": [
128
172
"Then we will wrap it in different runners for dynamic simulation."
129
173
]
130
174
},
131
175
{
132
176
"cell_type": "markdown",
133
177
"id": "1cbdeac2",
134
-
"metadata": {},
178
+
"metadata": {
179
+
"pycharm": {
180
+
"name": "#%% md\n"
181
+
}
182
+
},
135
183
"source": [
136
184
"## ``brainpy.DSRunner``"
137
185
]
138
186
},
139
187
{
140
188
"cell_type": "markdown",
141
189
"id": "23e41c2d",
142
-
"metadata": {},
190
+
"metadata": {
191
+
"pycharm": {
192
+
"name": "#%% md\n"
193
+
}
194
+
},
143
195
"source": [
144
196
"``brainpy.DSRunner`` aims to provide model simulation with an outstanding performance. It takes advantage of the [structural loop primitive](../tutorial_math/control_flows.ipynb) to lower the model onto the XLA devices. "
145
197
]
@@ -148,7 +200,11 @@
148
200
"cell_type": "code",
149
201
"execution_count": 3,
150
202
"id": "e0d0127e",
151
-
"metadata": {},
203
+
"metadata": {
204
+
"pycharm": {
205
+
"name": "#%%\n"
206
+
}
207
+
},
152
208
"outputs": [
153
209
{
154
210
"data": {
@@ -190,7 +246,10 @@
190
246
"execution_count": 4,
191
247
"id": "7190e822",
192
248
"metadata": {
193
-
"scrolled": false
249
+
"scrolled": false,
250
+
"pycharm": {
251
+
"name": "#%%\n"
252
+
}
194
253
},
195
254
"outputs": [
196
255
{
@@ -213,31 +272,47 @@
213
272
{
214
273
"cell_type": "markdown",
215
274
"id": "b8b45777",
216
-
"metadata": {},
275
+
"metadata": {
276
+
"pycharm": {
277
+
"name": "#%% md\n"
278
+
}
279
+
},
217
280
"source": [
218
281
"Note that if the parameter ``jit`` is set to ``True``, then all the variables will be JIT compiled and thus the system cannot be debugged by Python debugging tools. For debugging, users can set ``jit=False``."
219
282
]
220
283
},
221
284
{
222
285
"cell_type": "markdown",
223
286
"id": "3d9e82a9",
224
-
"metadata": {},
287
+
"metadata": {
288
+
"pycharm": {
289
+
"name": "#%% md\n"
290
+
}
291
+
},
225
292
"source": [
226
293
"## ``brainpy.ReportRunner``"
227
294
]
228
295
},
229
296
{
230
297
"cell_type": "markdown",
231
298
"id": "eaab18b7",
232
-
"metadata": {},
299
+
"metadata": {
300
+
"pycharm": {
301
+
"name": "#%% md\n"
302
+
}
303
+
},
233
304
"source": [
234
305
"``brainpy.ReportRunner`` aims to provide a Pythonic interface for model debugging. Users can use the standard Python debugging tools when simulating the model with ``ReportRunner``."
235
306
]
236
307
},
237
308
{
238
309
"cell_type": "markdown",
239
310
"id": "cb659ddd",
240
-
"metadata": {},
311
+
"metadata": {
312
+
"pycharm": {
313
+
"name": "#%% md\n"
314
+
}
315
+
},
241
316
"source": [
242
317
"The drawback of the ``brainpy.ReportRunner`` is that it is relatively slow. It iterates the loop along times during the simulation."
243
318
]
@@ -246,7 +321,11 @@
246
321
"cell_type": "code",
247
322
"execution_count": 4,
248
323
"id": "a6c62e4b",
249
-
"metadata": {},
324
+
"metadata": {
325
+
"pycharm": {
326
+
"name": "#%%\n"
327
+
}
328
+
},
250
329
"outputs": [
251
330
{
252
331
"data": {
@@ -286,7 +365,11 @@
286
365
{
287
366
"cell_type": "markdown",
288
367
"id": "d5b1aa9c",
289
-
"metadata": {},
368
+
"metadata": {
369
+
"pycharm": {
370
+
"name": "#%% md\n"
371
+
}
372
+
},
290
373
"source": [
291
374
"We can see from the output that the time spent for simulation through ``ReportRunner`` is longer than that through ``DSRunner``."
0 commit comments