brainpy-largescale depends on brainpy
Project description
brainpy-largescale
Run BrainPy in multiple processes.
brainpy-largescale depends on BrainPy and brainpy-lib, use the following instructions to install brainpy package.
Install
Only support Linux
pip install brainpy-largescale
Import
import brainpy as bp
import bpl
Set platform
bpl.set_platform('cpu')
only support cpu.
Create population
Use Leaky Integrate-and-Fire (LIF)
a = bpl.neurons.LIF(300, V_rest=-60., V_th=-50., V_reset=-60., tau=20., tau_ref=5.)
b = bpl.neurons.LIF(100, V_rest=-60., V_th=-50., V_reset=-60., tau=20., tau_ref=5.)
Create synapse
d = bpl.synapses.Exponential(a, b, bp.conn.FixedProb(0.4, seed=123), g_max=10, tau=5., delay_step=1)
Construct network
net = bpl.Network(a, b, d)
net.build()
Add input
add current input
inputs = [bpl.device.Input(a, 20), bpl.device.Input(b, 10)]
Add spike monitor
monitor_spike = bpl.device.Monitor([a, b], bpl.device.MonitorKey.spike)
Add volt monitor
monitor_volt = bpl.device.Monitor([b], bpl.device.MonitorKey.volt)
monitors = [monitor_spike, monitor_volt]
Add spike and volt callback
def spike(a: List[Tuple[int, float]]):
if a:
print(a)
def volt(a: List[Tuple[int, float, float]]):
# print(a)
pass
Run
runner = bpl.runner.DSRunner(
net,
monitors=monitors,
inputs=inputs,
jit=False,
spike_callback=spike,
volt_callback=volt,
)
runner.run(10.)
Visualization
import matplotlib.pyplot as plt
if 'spike' in runner.mon:
bp.visualize.raster_plot(runner.mon.ts, runner.mon['spike'], show=True)
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brainpy-largescale-0.1.2.tar.gz
(20.0 kB
view details)
Built Distribution
File details
Details for the file brainpy-largescale-0.1.2.tar.gz
.
File metadata
- Download URL: brainpy-largescale-0.1.2.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79cdf66a7c58a076f0264c8959c22fe717f728839e3f54e6e6d6672e47349d85 |
|
MD5 | 98f02204fae1df605d1e01d1f295e9b3 |
|
BLAKE2b-256 | 45319a76166801ffd3e0dfbc9aadf7f28771d549b867d3fc28433ac3f15dc34b |
File details
Details for the file brainpy_largescale-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: brainpy_largescale-0.1.2-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a20f6e46f2df87ea99251f412f9de08be130706497f23ef8ceee345463b130b |
|
MD5 | e3298a12ed5b9ad98b8c2cb70065b7c5 |
|
BLAKE2b-256 | 3ed5e8eff7a78b594ecae64786777ec12982ee2ce38ba03c6dbfa99a8d898259 |