BrainPy-Models
Note: We welcome your contributions for model implementations.
BrainPy-Models is a repository accompany with BrainPy, which is a framework for spiking neural network simulation. With BrainPy, we implements the most canonical and effective neuron models and synapse models, and show them in BrainPy-Models.
Here, users can directly import our models into your network, and also can learn examples of how to use BrainPy from Documentations.
We provide the following models:
Installation
Install from source code:
python setup.py install
Install BrainPy-Models using conda:
conda install bpmodels -c brainpy
Install BrainPy-Models using pip:
pip install bpmodels
The following packages need to be installed to use BrainPy-Models:
- Python >= 3.7
- Matplotlib >= 2.0
- brainpy-simulator >= 0.3.0
Quick Start
The use of bpmodels is very convenient, let's take an example of the implementation of the E-I balanced network.
We start by importing the brainpy and bpmodels packages and set profile.
import brainpy as bp
import bpmodels
import numpy as np
import matplotlib.pyplot as plt
# set profile
bp.profile.set(jit=True, device='cpu',
numerical_method='exponential')
The E-I balanced network is based on leaky Integrate-and-Fire (LIF) neurons connecting with single exponential decay synapses. As showed in the table above, bpmodels provides pre-defined LIF neuron model and exponential synapse model, so we can use bpmodels.neurons.get_LIF and bpmodels.synapses.get_exponential to get the pre-defined models.
V_rest = -52.
V_reset = -60.
V_th = -50.
neu = bpmodels.neurons.get_LIF(V_rest=V_rest, V_reset = V_reset, V_th=V_th, noise=0., mode='scalar')
syn = bpmodels.synapses.get_exponential(tau_decay = 2., mode='scalar')
# build network
num_exc = 500
num_inh = 500
prob = 0.1
JE = 1 / np.sqrt(prob * num_exc)
JI = 1 / np.sqrt(prob * num_inh)
group = bp.NeuGroup(neu, geometry=num_exc + num_inh, monitors=['spike'])
group.ST['V'] = np.random.random(num_exc + num_inh) * (V_th - V_rest) + V_rest
exc_conn = bp.SynConn(syn,
pre_group=group[:num_exc],
post_group=group,
conn=bp.connect.FixedProb(prob=prob))
exc_conn.ST['w'] = JE
inh_conn = bp.SynConn(syn,
pre_group=group[num_exc:],
post_group=group,
conn=bp.connect.FixedProb(prob=prob))
exc_conn.ST['w'] = -JI
net = bp.Network(group, exc_conn, inh_conn)
net.run(duration=500., inputs=(group, 'ST.input', 3.))
# visualization
fig, gs = bp.visualize.get_figure(4, 1, 2, 10)
fig.add_subplot(gs[:3, 0])
bp.visualize.raster_plot(net.ts, group.mon.spike, xlim=(50, 450))
fig.add_subplot(gs[3, 0])
rates = bp.measure.firing_rate(group.mon.spike, 5.)
plt.plot(net.ts, rates)
plt.xlim(50, 450)
plt.show()
Then you would expect to see the following output:
Metadata
Release files for bpmodels 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bpmodels-0.2.3.tar.gz | 43.2 kB | Without provenance | Details for bpmodels-0.2.3.tar.gz |
Release files / bpmodels-0.2.3.tar.gz
| Download URL | bpmodels-0.2.3.tar.gz |
|---|---|
| Size | 43.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db6d9d73ff2d9e93c510fa0bc7430fa21dde05c7eed85674e820f7a9b991ff58
|
|
BLAKE2b-256 checksum How to use checksums |
b8059bbd90c3578d8d92eb63f8adcc77a8220f8b15e6b99c73cda840f7a5f771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for bpmodels 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.