Giter VIP home page Giter VIP logo

examples's Introduction

Header image of BrainPy - brain dynamics programming in Python.

Supported Python Version LICENSE Documentation PyPI version Continuous Integration Continuous Integration with Models

BrainPy is a flexible, efficient, and extensible framework for computational neuroscience and brain-inspired computation based on the Just-In-Time (JIT) compilation (built on top of JAX, Taichi, Numba, and others). It provides an integrative ecosystem for brain dynamics programming, including brain dynamics building, simulation, training, analysis, etc.

Installation

BrainPy is based on Python (>=3.8) and can be installed on Linux (Ubuntu 16.04 or later), macOS (10.12 or later), and Windows platforms.

For detailed installation instructions, please refer to the documentation: Quickstart/Installation

Using BrainPy with docker

We provide a docker image for BrainPy. You can use the following command to pull the image:

$ docker pull brainpy/brainpy:latest

Then, you can run the image with the following command:

$ docker run -it --platform linux/amd64 brainpy/brainpy:latest

Using BrainPy with Binder

We provide a Binder environment for BrainPy. You can use the following button to launch the environment:

Binder

Ecosystem

Citing

BrainPy is developed by a team in Neural Information Processing Lab at Peking University, China. Our team is committed to the long-term maintenance and development of the project.

If you are using brainpy, please consider citing the corresponding papers.

Ongoing development plans

We highlight the key features and functionalities that are currently under active development.

We also welcome your contributions (see Contributing to BrainPy).

  • model and data parallelization on multiple devices for dense connection models
  • model parallelization on multiple devices for sparse spiking network models
  • data parallelization on multiple devices for sparse spiking network models
  • pipeline parallelization on multiple devices for sparse spiking network models
  • multi-compartment modeling
  • measurements, analysis, and visualization methods for large-scale spiking data
  • Online learning methods for large-scale spiking network models
  • Classical plasticity rules for large-scale spiking network models

examples's People

Contributors

chaoming0625 avatar pikapei avatar routhleck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

examples's Issues

Errors in Import brainpy

I can pip the packages brainpy, braipylib, jax, jaxlib successfully according to the documentation guide, but when I import brainpy in my script the error occurs: "AttributeError: module 'jax' has no attribute 'version' ", I have no idea why this appears, and found no solutions. Any help is appreciated. Thank you.

TypeError in mnist_lif_readout.py

Came from #9. Thanks for solving that problem!
There's another error in the same example:

Namespace(T=100, platform='cpu', batch=64, epochs=15, out_dir='./logs', lr=0.001, tau=2.0)
Traceback (most recent call last):
  File "/Users/pei/project/computational-neuroscience/mnist_lif_readout.py", line 103, in <module>
    l, correct_num = train(X, Y)
                     ^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/jit.py", line 208, in __call__
    rets = self._get_transform(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/jit.py", line 155, in _get_transform
    self._dyn_vars, rets = evaluate_dyn_vars(
                           ^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/tools.py", line 101, in evaluate_dyn_vars
    rets = jax.eval_shape(f2, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/project/computational-neuroscience/mnist_lif_readout.py", line 86, in train
    grads, l, n = grad_fun(xs, ys)
                  ^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/autograd.py", line 209, in __call__
    rets = self._transform(
           ^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/autograd.py", line 133, in _f_grad_with_aux_to_transform
    outputs = self.target(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/project/computational-neuroscience/mnist_lif_readout.py", line 69, in loss_fun
    out_fr = jnp.mean(outs, axis=0)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/jax/_src/numpy/reductions.py", line 319, in mean
    return _mean(a, _ensure_optional_axes(axis), dtype, out, keepdims,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/jax/_src/numpy/reductions.py", line 351, in _mean
    sum(a, axis, dtype=computation_dtype, keepdims=keepdims, where=where),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/jax/_src/numpy/reductions.py", line 222, in sum
    return _reduce_sum(a, axis=_ensure_optional_axes(axis), dtype=dtype, out=out,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/jax/_src/numpy/reductions.py", line 212, in _reduce_sum
    return _reduction(a, "sum", np.sum, lax.add, 0, preproc=_cast_to_numeric,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/jax/_src/numpy/reductions.py", line 94, in _reduction
    a = a if isinstance(a, Array) else lax_internal.asarray(a)
                                       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: asarray: expected ArrayLike, got Traced<ShapedArray(float32[100,64,10])>with<DynamicJaxprTrace(level=5/0)> of type <class 'brainpy._src.math.ndarray.Array'>.

I found a subtle bug in CANN tutorial

Hi! I found a bug in CANN tutorial that module bp is miswritten as op both in .py (line 75) and .ipynb (line 64) files. i.e.

self.integral = op.odeint(self.derivative)

should be

self.integral = bp.odeint(self.derivative)

'PoissonEncoder' object is not callable

Hello,

When I ran this example https://github.com/brainpy/examples/blob/main/brain_inspired_computing/mnist_lif_readout.py, the error showed:

Namespace(T=100, platform='cpu', batch=64, epochs=15, out_dir='./logs', lr=0.001, tau=2.0)
Traceback (most recent call last):
  File "/Users/pei/Downloads/mnist_lif_readout.py", line 103, in <module>
    l, correct_num = train(X, Y)
                     ^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/jit.py", line 208, in __call__
    rets = self._get_transform(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/jit.py", line 155, in _get_transform
    self._dyn_vars, rets = evaluate_dyn_vars(
                           ^^^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/tools.py", line 101, in evaluate_dyn_vars
    rets = jax.eval_shape(f2, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/Downloads/mnist_lif_readout.py", line 86, in train
    grads, l, n = grad_fun(xs, ys)
                  ^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/autograd.py", line 209, in __call__
    rets = self._transform(
           ^^^^^^^^^^^^^^^^
  File "/Users/pei/.pyenv/versions/mambaforge-22.9.0-2/envs/brainpy-env/lib/python3.11/site-packages/brainpy/_src/math/object_transform/autograd.py", line 133, in _f_grad_with_aux_to_transform
    outputs = self.target(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pei/Downloads/mnist_lif_readout.py", line 65, in loss_fun
    xs = encoder(xs, num_step=args.T)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'PoissonEncoder' object is not callable

Any help would be appreciated. Thank you!

error on numpy_ops.py

I try the https://brainpy-examples.readthedocs.io/en/latest/neurons/JR_1995_jansen_rit_model.html

python jansen_rit_model_001.py
Traceback (most recent call last):
  File "C:\PythonProjects\test_brainmodels\jansen_rit_model_001.py", line 1, in <module>
    import brainpy as bp
  File "C:\Python312\Lib\site-packages\brainpy\__init__.py", line 28, in <module>
    from . import math
  File "C:\Python312\Lib\site-packages\brainpy\math\__init__.py", line 35, in <module>
    from .delayvars import *
  File "C:\Python312\Lib\site-packages\brainpy\math\delayvars.py", line 12, in <module>
    from brainpy.math import numpy_ops as bm
  File "C:\Python312\Lib\site-packages\brainpy\math\numpy_ops.py", line 354, in <module>
    @wraps(jnp.in1d)
           ^^^^^^^^
  File "C:\Python312\Lib\site-packages\jax\_src\deprecations.py", line 54, in getattr
    raise AttributeError(f"module {module!r} has no attribute {name!r}")
AttributeError: module 'jax.numpy' has no attribute 'in1d'. Did you mean: 'int16'?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.