|
133 | 133 | }, |
134 | 134 | { |
135 | 135 | "cell_type": "code", |
136 | | - "execution_count": 15, |
| 136 | + "execution_count": 9, |
137 | 137 | "outputs": [], |
138 | 138 | "source": [ |
139 | 139 | "current = bm.linspace(1, 10.1, 10) # here only one parameter" |
|
153 | 153 | }, |
154 | 154 | { |
155 | 155 | "cell_type": "code", |
156 | | - "execution_count": 16, |
| 156 | + "execution_count": 10, |
157 | 157 | "outputs": [ |
158 | 158 | { |
159 | 159 | "data": { |
160 | 160 | "text/plain": " 0%| | 0/10 [00:00<?, ?it/s]", |
161 | 161 | "application/vnd.jupyter.widget-view+json": { |
162 | 162 | "version_major": 2, |
163 | 163 | "version_minor": 0, |
164 | | - "model_id": "c84de99cfcad4b528dc75cc44f911b3e" |
| 164 | + "model_id": "8760d226fe2743619106637872b9b4f4" |
165 | 165 | } |
166 | 166 | }, |
167 | 167 | "metadata": {}, |
168 | 168 | "output_type": "display_data" |
169 | 169 | }, |
170 | 170 | { |
171 | 171 | "data": { |
172 | | - "text/plain": "[0, 1, 0, 0, 0, 0, 60, 62, 66, 68]" |
| 172 | + "text/plain": "[0, 0, 0, 48, 53, 57, 60, 63, 66, 68]" |
173 | 173 | }, |
174 | | - "execution_count": 16, |
| 174 | + "execution_count": 10, |
175 | 175 | "metadata": {}, |
176 | 176 | "output_type": "execute_result" |
177 | 177 | } |
|
198 | 198 | }, |
199 | 199 | { |
200 | 200 | "cell_type": "code", |
201 | | - "execution_count": 12, |
| 201 | + "execution_count": 11, |
202 | 202 | "outputs": [], |
203 | 203 | "source": [ |
204 | 204 | "def hh_spike_num2(bg_current): # \"input\" is the bg_current\n", |
205 | 205 | " import brainpy as bp # needed to reimport packages when\n", |
206 | 206 | " # run the function in Jupyter\n", |
207 | 207 | "\n", |
208 | | - " bg_current = bm.as_jax(bg_current)\n", |
| 208 | + " bg_current = bp.math.as_jax(bg_current)\n", |
209 | 209 | " model = bp.neurons.HH(1)\n", |
210 | 210 | " runner = bp.dyn.DSRunner(model, monitors=['spike'], inputs=['input', bg_current])\n", |
211 | 211 | " runner.run(1000.)\n", |
|
228 | 228 | }, |
229 | 229 | { |
230 | 230 | "cell_type": "code", |
231 | | - "execution_count": 17, |
| 231 | + "execution_count": 12, |
232 | 232 | "outputs": [ |
233 | 233 | { |
234 | 234 | "data": { |
235 | 235 | "text/plain": " 0%| | 0/10 [00:00<?, ?it/s]", |
236 | 236 | "application/vnd.jupyter.widget-view+json": { |
237 | 237 | "version_major": 2, |
238 | 238 | "version_minor": 0, |
239 | | - "model_id": "a85026f739154dfd9627ecd4964aabb3" |
| 239 | + "model_id": "10d02874c8584954a79129168536accd" |
240 | 240 | } |
241 | 241 | }, |
242 | 242 | "metadata": {}, |
243 | 243 | "output_type": "display_data" |
244 | 244 | }, |
245 | 245 | { |
246 | 246 | "data": { |
247 | | - "text/plain": "[0, 1, 0, 0, 53, 57, 58, 63, 65, 68]" |
| 247 | + "text/plain": "[0, 0, 1, 47, 0, 57, 60, 63, 66, 68]" |
248 | 248 | }, |
249 | | - "execution_count": 17, |
| 249 | + "execution_count": 12, |
250 | 250 | "metadata": {}, |
251 | 251 | "output_type": "execute_result" |
252 | 252 | } |
|
261 | 261 | "collapsed": false |
262 | 262 | } |
263 | 263 | }, |
| 264 | + { |
| 265 | + "cell_type": "markdown", |
| 266 | + "source": [ |
| 267 | + "If you think that the order of the running results does not matter, you can also use ``cpu_unordered_parallel()`` function. This can maximize the running efficiency of all processors, since all workers run with a non-blocking and unordered manner." |
| 268 | + ], |
| 269 | + "metadata": { |
| 270 | + "collapsed": false |
| 271 | + } |
| 272 | + }, |
264 | 273 | { |
265 | 274 | "cell_type": "markdown", |
266 | 275 | "source": [ |
|
313 | 322 | }, |
314 | 323 | { |
315 | 324 | "cell_type": "code", |
316 | | - "execution_count": 18, |
| 325 | + "execution_count": 3, |
317 | 326 | "outputs": [], |
318 | 327 | "source": [ |
319 | 328 | "def hh_spike_num3(bg_current): # \"input\" is the bg_current\n", |
|
329 | 338 | }, |
330 | 339 | { |
331 | 340 | "cell_type": "code", |
332 | | - "execution_count": 19, |
| 341 | + "execution_count": 14, |
333 | 342 | "outputs": [ |
334 | 343 | { |
335 | 344 | "data": { |
336 | 345 | "text/plain": " 0%| | 0/10000 [00:00<?, ?it/s]", |
337 | 346 | "application/vnd.jupyter.widget-view+json": { |
338 | 347 | "version_major": 2, |
339 | 348 | "version_minor": 0, |
340 | | - "model_id": "63fd00c7f08c4f89891c286bcad2b55d" |
| 349 | + "model_id": "a0c1b9e2544c4b7d9324b5a1d257dab8" |
341 | 350 | } |
342 | 351 | }, |
343 | 352 | "metadata": {}, |
|
349 | 358 | "application/vnd.jupyter.widget-view+json": { |
350 | 359 | "version_major": 2, |
351 | 360 | "version_minor": 0, |
352 | | - "model_id": "4826a51fb553470fa0fb4149a5b3d7e6" |
| 361 | + "model_id": "9e534fb4c06d445b8df7ed5300d25bd1" |
353 | 362 | } |
354 | 363 | }, |
355 | 364 | "metadata": {}, |
|
361 | 370 | "application/vnd.jupyter.widget-view+json": { |
362 | 371 | "version_major": 2, |
363 | 372 | "version_minor": 0, |
364 | | - "model_id": "2dacbf527e5e4b2f8a83be2cc94d3560" |
| 373 | + "model_id": "3d7cb69912994ee7ac3e44cde95373b8" |
365 | 374 | } |
366 | 375 | }, |
367 | 376 | "metadata": {}, |
|
373 | 382 | "application/vnd.jupyter.widget-view+json": { |
374 | 383 | "version_major": 2, |
375 | 384 | "version_minor": 0, |
376 | | - "model_id": "1224b579ba7d49e4a930f6e7ce2d82fe" |
| 385 | + "model_id": "903708f92cbf4e2086157712080635b7" |
377 | 386 | } |
378 | 387 | }, |
379 | 388 | "metadata": {}, |
380 | 389 | "output_type": "display_data" |
381 | 390 | }, |
382 | 391 | { |
383 | 392 | "data": { |
384 | | - "text/plain": "JaxArray([ 0, 1, 1, 47, 53, 57, 45, 62, 66, 68], dtype=int32)" |
| 393 | + "text/plain": "JaxArray([ 0, 0, 0, 0, 0, 0, 60, 63, 66, 68], dtype=int32)" |
385 | 394 | }, |
386 | | - "execution_count": 19, |
| 395 | + "execution_count": 14, |
387 | 396 | "metadata": {}, |
388 | 397 | "output_type": "execute_result" |
389 | 398 | } |
|
408 | 417 | }, |
409 | 418 | { |
410 | 419 | "cell_type": "code", |
411 | | - "execution_count": 20, |
| 420 | + "execution_count": 15, |
412 | 421 | "outputs": [ |
413 | 422 | { |
414 | 423 | "data": { |
415 | 424 | "text/plain": " 0%| | 0/10000 [00:00<?, ?it/s]", |
416 | 425 | "application/vnd.jupyter.widget-view+json": { |
417 | 426 | "version_major": 2, |
418 | 427 | "version_minor": 0, |
419 | | - "model_id": "845008715fb04111bea98520eb0d140e" |
| 428 | + "model_id": "ff15303b2a394ce488fcf4d65ce3eca8" |
420 | 429 | } |
421 | 430 | }, |
422 | 431 | "metadata": {}, |
|
428 | 437 | "application/vnd.jupyter.widget-view+json": { |
429 | 438 | "version_major": 2, |
430 | 439 | "version_minor": 0, |
431 | | - "model_id": "919c9c8484144eb48a77d7172162b599" |
| 440 | + "model_id": "52b82eeb8c874946aeceaed549fc024b" |
432 | 441 | } |
433 | 442 | }, |
434 | 443 | "metadata": {}, |
|
440 | 449 | "application/vnd.jupyter.widget-view+json": { |
441 | 450 | "version_major": 2, |
442 | 451 | "version_minor": 0, |
443 | | - "model_id": "dda8f8878d1643ec9c4bdfd2bab5be9f" |
| 452 | + "model_id": "f974774c2e1948bb87b1307d34bc69ee" |
444 | 453 | } |
445 | 454 | }, |
446 | 455 | "metadata": {}, |
|
452 | 461 | "application/vnd.jupyter.widget-view+json": { |
453 | 462 | "version_major": 2, |
454 | 463 | "version_minor": 0, |
455 | | - "model_id": "e21c4351ca884c43a54df14763b1373d" |
| 464 | + "model_id": "7ba11b94834d435eb1791948c8db2048" |
456 | 465 | } |
457 | 466 | }, |
458 | 467 | "metadata": {}, |
459 | 468 | "output_type": "display_data" |
460 | 469 | }, |
461 | 470 | { |
462 | 471 | "data": { |
463 | | - "text/plain": "array([ 0, 0, 1, 48, 53, 57, 60, 63, 66, 68])" |
| 472 | + "text/plain": "array([ 0, 0, 0, 0, 0, 55, 58, 59, 65, 68])" |
464 | 473 | }, |
465 | | - "execution_count": 20, |
| 474 | + "execution_count": 15, |
466 | 475 | "metadata": {}, |
467 | 476 | "output_type": "execute_result" |
468 | 477 | } |
|
532 | 541 | }, |
533 | 542 | { |
534 | 543 | "cell_type": "code", |
535 | | - "execution_count": 21, |
| 544 | + "execution_count": 4, |
536 | 545 | "outputs": [ |
537 | 546 | { |
538 | 547 | "data": { |
539 | 548 | "text/plain": " 0%| | 0/10000 [00:00<?, ?it/s]", |
540 | 549 | "application/vnd.jupyter.widget-view+json": { |
541 | 550 | "version_major": 2, |
542 | 551 | "version_minor": 0, |
543 | | - "model_id": "309900c672e7486cac5ef417b2e821de" |
| 552 | + "model_id": "ffad3289fd574502a4a4862ab1f767fe" |
544 | 553 | } |
545 | 554 | }, |
546 | 555 | "metadata": {}, |
547 | 556 | "output_type": "display_data" |
548 | 557 | }, |
549 | 558 | { |
550 | 559 | "data": { |
551 | | - "text/plain": " 0%| | 0/10000 [00:00<?, ?it/s]", |
552 | | - "application/vnd.jupyter.widget-view+json": { |
553 | | - "version_major": 2, |
554 | | - "version_minor": 0, |
555 | | - "model_id": "9dedc7a8c96c4f6ab4d290f246b94274" |
556 | | - } |
557 | | - }, |
558 | | - "metadata": {}, |
559 | | - "output_type": "display_data" |
560 | | - }, |
561 | | - { |
562 | | - "data": { |
563 | | - "text/plain": "array([ 0, 0, 0, 0, 0, 0, 0, 49, 52, 54, 0, 50, 59, 61, 62, 63, 65,\n 66, 67, 68])" |
| 560 | + "text/plain": "array([ 0, 0, 0, 0, 0, 0, 0, 49, 52, 54, 56, 58, 59, 61, 62, 63, 65,\n 66, 67, 68])" |
564 | 561 | }, |
565 | | - "execution_count": 21, |
| 562 | + "execution_count": 4, |
566 | 563 | "metadata": {}, |
567 | 564 | "output_type": "execute_result" |
568 | 565 | } |
569 | 566 | ], |
570 | 567 | "source": [ |
571 | | - "bp.math.set_host_device_count(10)\n", |
| 568 | + "bp.math.set_host_device_count(10) # this should place on the top of the file\n", |
572 | 569 | "current = bm.linspace(1., 10.1, 20)\n", |
573 | | - "r = bp.running.jax_vectorize_map(hh_spike_num3, [current], num_parallel=10, clear_buffer=True)\n", |
| 570 | + "r = bp.running.jax_parallelize_map(hh_spike_num3, [current], num_parallel=10, clear_buffer=True)\n", |
574 | 571 | "r" |
575 | 572 | ], |
576 | 573 | "metadata": { |
|
587 | 584 | } |
588 | 585 | }, |
589 | 586 | { |
590 | | - "cell_type": "code", |
591 | | - "execution_count": null, |
592 | | - "outputs": [], |
| 587 | + "cell_type": "markdown", |
593 | 588 | "source": [ |
| 589 | + "```python\n", |
| 590 | + "\n", |
594 | 591 | "#!/bin/bash\n", |
595 | 592 | "#SBATCH -J <name>\n", |
596 | 593 | "#SBATCH -o <file name>\n", |
|
599 | 596 | "#SBATCH -N <int>\n", |
600 | 597 | "#SBATCH -c <int>\n", |
601 | 598 | "\n", |
602 | | - "python your_script.py" |
| 599 | + "python your_script.py\n", |
| 600 | + "```" |
603 | 601 | ], |
604 | 602 | "metadata": { |
605 | 603 | "collapsed": false |
|
0 commit comments