Releases: brainpy/BrainPy
Version 2.2.3.5
fix `parameter()` bug (#286) fix `parameter()` bug
Version 2.2.3.4
New features
- This release removes the
extensions
package, and deploys it as a standalone repository as brainpylib. - Initializing
brainpy.math.random.RandomState
withseed_or_key
, rather thanseed
. - APIs in
brainpy.measure
supportsloop
andvmap
methods, the former is memory-efficient, and the later is faster. - DNN layers are revised and are all useable.
- Upgrade operators to match
brainpylib>=0.1.1
brainpy.math.pre2post_event_sum
supports atuodiff (including JVP, VJP), it can be used for SNN training.
Full Changelog: V2.2.3.3...V2.2.3.4
Version 2.2.3.3
fix delay update bug (#281 fix delay update bug
Version 2.2.3.2
This release continuously improves the functionality of BrainPy
New features
- Add
brainpy.measure.unitary_LFP()
for calculating LFP from neuronal spikes
>>> import brainpy as bp
>>> runner = bp.DSRunner()
>>> runner.run(100)
>>> lfp = bp.measure.unitary_LFP(runner.mon.ts, runner.mon['exc.spike'], 'exc')
>>> lfp += bp.measure.unitary_LFP(runner.mon.ts, runner.mon['inh.spike'], 'inh')
- Add
brainpy.synapses.PoissonInput
model
>>> bp.synapse.PoissonInput(target_variable, num_input, freq, weight)
- Upgrade brainpy connection methods, improving its speeds. New customization of brainpy
Connector
can be implemented through
class YourConnector(bp.conn.TwoEndConnector):
def build_csr(self):
pass
def build_coo(self):
pass
def build_mat(self):
pass
Improvements
-
Support transformation contexts for
JaxArray
, and improve the error checking of JaxArray updating in a JIT function. -
Speedup delay retrieval by reversing delay variable data.
-
Improve the operator customization methods by using Numba functions.
-
Fix bugs in GPU operators in
brainpylib
.
What's Changed
- Docs: add compile_brainpylib documentation by @ztqakita in #270
- add
PoissonInput
model andunitary_LFP()
method by @chaoming0625 in #271 - organize brainpylib for future extensions by @chaoming0625 in #272
- Update lowdim analyzer by @ztqakita in #273
- speedup connections in One2One, All2All, GridFour, GridEight, and others by @chaoming0625 in #274
- consistent brainpylib with brainpy operators by @chaoming0625 in #275
- Fix test bugs by @chaoming0625 in #276
- Fixed setup mac script by @ztqakita in #278
- JaxArray transformation context by @chaoming0625 in #277
- speedup delay retrieval by reversing delay variable data by @chaoming0625 in #279
- Updating apis for connections and operation registeration by @chaoming0625 in #280
Full Changelog: V2.2.3.1...V2.2.3.2
Version 2.2.3.1
This release fixes the installation on Windows systems and improves the installation guides in the official documentation and installation process.
The following example shows how to install jaxlib
after users install and import brainpy
:
>>> import brainpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\adadu\miniconda3\envs\py3test\lib\site-packages\brainpy\__init__.py", line 10, in <module>
raise ModuleNotFoundError(
BrainPy needs jaxlib, please install jaxlib.
1. If you are using Windows system, install jaxlib through
>>> pip install jaxlib -f https://whls.blob.core.windows.net/unstable/index.html
2. If you are using macOS platform, install jaxlib through
>>> pip install jaxlib -f https://storage.googleapis.com/jax-releases/jax_releases.html
3. If you are using Linux platform, install jaxlib through
>>> pip install jaxlib -f https://storage.googleapis.com/jax-releases/jax_releases.html
4. If you are using Linux + CUDA platform, install jaxlib through
>>> pip install jaxlib -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
Note that the versions of "jax" and "jaxlib" should be consistent, like "jax=0.3.14", "jaxlib=0.3.14".
More detail installation instruction, please see https://brainpy.readthedocs.io/en/latest/quickstart/installation.html#dependency-2-jax
Hope this information may help the installation of BrainPy much easiler.
Version 2.2.3
This release continues to improve the usability of BrainPy.
New Features
- Operations among a
JaxArray
and a NumPyndarray
in a JIT function no longer cause errors.
>>> import numpy as np
>>> import brainpy.math as bm
>>> f = bm.jit(lambda: bm.random.random(3) + np.ones(1))
>>> f
JaxArray([1.2022058, 1.683937 , 1.3586301], dtype=float32)
- Initializing a
brainpy.math.Variable
according to the data shape.
>>> bm.Variable(10, dtype=bm.float32)
Variable([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)
LengthDelay
supports a new method called"concatenate"
which is compatible with BP training.
>>> delay = bm.LengthDelay(bm.ones(3), 10, update_method='concatenate')
>>> delay.update(bm.random.random(3))
>>> delay.retrieve(0)
DeviceArray([0.17887115, 0.6738142 , 0.75816643], dtype=float32)
>>> delay.retrieve(10)
DeviceArray([0., 0., 0.], dtype=float32)
Note that compared with the default updating method "rotation"
, this method can be used to train delay models with BP algorithms. However, "concatenate"
has a slower speed for delay processing.
- Support customizing the plotting styles of fixed points. However, there is still work to support flexible plotting of analyzed results.
>>> from brainpy.analysis import plotstyle, stability
>>> plotstyle.set_plot_schema(stability.SADDLE_NODE, marker='*', markersize=15)
Full Changelog: V2.2.2...V2.2.3
What's Changed
- Update installation info and delay apis by @chaoming0625 in #263
- Support initializing a Variable by data shape by @chaoming0625 in #265
- operations with JaxArray and numpy ndarray do not cause errors by @chaoming0625 in #266
- Update
VariableView
and analysis plotting apis by @chaoming0625 in #268
Full Changelog: V2.2.2...V2.2.3
Version 2.2.2
Bug Fixes
This release fixes several bugs in the BrainPy system, including:
- The jitted functions in
brainpy.measure
module no longer exists when they are cleared bybrainpy.math.clear_memory_buffer()
. - The bug for
clear_input()
function. - The bug for the monitor in
brainpy.integrators.IntegratorRunner
What's Changed
- update loop docs and apis by @chaoming0625 in #261
- fix some bugs by @chaoming0625 in #262
Full Changelog: V2.2.1...V2.2.2
Version 2.2.1
This release fixes bugs found in the codebase and improves the usability and functions of BrainPy.
Bug fixes
- Fix the bug of operator customization in
brainpy.math.XLACustomOp
andbrainpy.math.register_op
. Now, it supports operator customization by using NumPy and Numba interface. For instance,
import brainpy.math as bm
def abs_eval(events, indices, indptr, post_val, values):
return post_val
def con_compute(outs, ins):
post_val = outs
events, indices, indptr, _, values = ins
for i in range(events.size):
if events[i]:
for j in range(indptr[i], indptr[i + 1]):
index = indices[j]
old_value = post_val[index]
post_val[index] = values + old_value
event_sum = bm.XLACustomOp(eval_shape=abs_eval, con_compute=con_compute)
- Fix the bug of
brainpy.tools.DotDict
. Now, it is compatible with the transformations of JAX. For instance,
import brainpy as bp
from jax import vmap
@vmap
def multiple_run(I):
hh = bp.neurons.HH(1)
runner = bp.dyn.DSRunner(hh, inputs=('input', I), numpy_mon_after_run=False)
runner.run(100.)
return runner.mon
mon = multiple_run(bp.math.arange(2, 10, 2))
New features
- Add numpy operators
brainpy.math.mat
,brainpy.math.matrix
,brainpy.math.asmatrix
. - Improve translation rules of brainpylib operators, improve its running speeds.
- Support
DSView
ofDynamicalSystem
instance. Now, it supports defining models with a slice view of a DS instance. For example,
import brainpy as bp
import brainpy.math as bm
class EINet_V2(bp.dyn.Network):
def __init__(self, scale=1.0, method='exp_auto'):
super(EINet_V2, self).__init__()
# network size
num_exc = int(3200 * scale)
num_inh = int(800 * scale)
# neurons
self.N = bp.neurons.LIF(num_exc + num_inh,
V_rest=-60., V_th=-50., V_reset=-60., tau=20., tau_ref=5.,
method=method, V_initializer=bp.initialize.Normal(-55., 2.))
# synapses
we = 0.6 / scale # excitatory synaptic weight (voltage)
wi = 6.7 / scale # inhibitory synaptic weight
self.Esyn = bp.synapses.Exponential(pre=self.N[:num_exc], post=self.N,
conn=bp.connect.FixedProb(0.02),
g_max=we, tau=5.,
output=bp.synouts.COBA(E=0.),
method=method)
self.Isyn = bp.synapses.Exponential(pre=self.N[num_exc:], post=self.N,
conn=bp.connect.FixedProb(0.02),
g_max=wi, tau=10.,
output=bp.synouts.COBA(E=-80.),
method=method)
net = EINet_V2(scale=1., method='exp_auto')
# simulation
runner = bp.dyn.DSRunner(
net,
monitors={'spikes': net.N.spike},
inputs=[(net.N.input, 20.)]
)
runner.run(100.)
# visualization
bp.visualize.raster_plot(runner.mon.ts, runner.mon['spikes'], show=True)
Version 2.2.0
This release has provided important improvements for BrainPy, including usability, speed, functions, and others.
Backwards Incompatible changes
brainpy.nn
module is no longer supported and has been removed since version 2.2.0. Instead, users should usebrainpy.train
module for the training of BP algorithms, online learning, or offline learning algorithms, andbrainpy.algorithms
module for online / offline training algorithms.- The
update()
function for the model definition has been changed:
>>> # 2.1.x
>>>
>>> import brainpy as bp
>>>
>>> class SomeModel(bp.dyn.DynamicalSystem):
>>> def __init__(self, ):
>>> ......
>>> def update(self, t, dt):
>>> pass
>>> # 2.2.x
>>>
>>> import brainpy as bp
>>>
>>> class SomeModel(bp.dyn.DynamicalSystem):
>>> def __init__(self, ):
>>> ......
>>> def update(self, tdi):
>>> t, dt = tdi.t, tdi.dt
>>> pass
where tdi
can be defined with other names, like sha
, to represent the shared argument across modules.
Deprecations
brainpy.dyn.xxx (neurons)
andbrainpy.dyn.xxx (synapse)
are no longer supported. Please usebrainpy.neurons
,brainpy.synapses
modules.brainpy.running.monitor
has been removed.brainpy.nn
module has been removed.
New features
brainpy.math.Variable
receives abatch_axis
setting to represent the batch axis of the data.
>>> import brainpy.math as bm
>>> a = bm.Variable(bm.zeros((1, 4, 5)), batch_axis=0)
>>> a.value = bm.zeros((2, 4, 5)) # success
>>> a.value = bm.zeros((1, 2, 5)) # failed
MathError: The shape of the original data is (2, 4, 5), while we got (1, 2, 5) with batch_axis=0.
brainpy.train
providesbrainpy.train.BPTT
for back-propagation algorithms,brainpy.train.Onlinetrainer
for online training algorithms,brainpy.train.OfflineTrainer
for offline training algorithms.brainpy.Base
class supports_excluded_vars
setting to ignore variables when retrieving variables by usingBase.vars()
method.
>>> class OurModel(bp.Base):
>>> _excluded_vars = ('a', 'b')
>>> def __init__(self):
>>> super(OurModel, self).__init__()
>>> self.a = bm.Variable(bm.zeros(10))
>>> self.b = bm.Variable(bm.ones(20))
>>> self.c = bm.Variable(bm.random.random(10))
>>>
>>> model = OurModel()
>>> model.vars().keys()
dict_keys(['OurModel0.c'])
brainpy.analysis.SlowPointFinder
supports directly analyzing an instance ofbrainpy.dyn.DynamicalSystem
.
>>> hh = bp.neurons.HH(1)
>>> finder = bp.analysis.SlowPointFinder(hh, target_vars={'V': hh.V, 'm': hh.m, 'h': hh.h, 'n': hh.n})
brainpy.datasets
supports MNIST, FashionMNIST, and other datasets.- Supports defining conductance-based neuron models``.
>>> class HH(bp.dyn.CondNeuGroup):
>>> def __init__(self, size):
>>> super(HH, self).__init__(size)
>>>
>>> self.INa = channels.INa_HH1952(size, )
>>> self.IK = channels.IK_HH1952(size, )
>>> self.IL = channels.IL(size, E=-54.387, g_max=0.03)
brainpy.layers
module provides commonly used models for DNN and reservoir computing.- Support composable definition of synaptic models by using
TwoEndConn
,SynOut
,SynSTP
andSynLTP
.
>>> bp.synapses.Exponential(self.E, self.E, bp.conn.FixedProb(prob),
>>> g_max=0.03 / scale, tau=5,
>>> output=bp.synouts.COBA(E=0.),
>>> stp=bp.synplast.STD())
- Provide commonly used surrogate gradient function for spiking generation, including
brainpy.math.spike_with_sigmoid_grad
brainpy.math.spike_with_linear_grad
brainpy.math.spike_with_gaussian_grad
brainpy.math.spike_with_mg_grad
- Provide shortcuts for GPU memory management via
brainpy.math.disable_gpu_memory_preallocation()
, andbrainpy.math.clear_buffer_memory()
.
What's Changed
- fix #207: synapses update first, then neurons, finally delay variables by @chaoming0625 in #219
- docs: add logos by @ztqakita in #218
- Add the biological NMDA model by @c-xy17 in #221
- docs: fix mathjax problem by @ztqakita in #222
- Add the parameter R to the LIF model by @c-xy17 in #224
- new version of brainpy: V2.2.0-rc1 by @chaoming0625 in #226
- update training apis by @chaoming0625 in #227
- Update quickstart and the analysis module by @c-xy17 in #229
- Eseential updates for montors, analysis, losses, and examples by @chaoming0625 in #230
- add numpy op tests by @ztqakita in #231
- Integrated simulation, simulaton and analysis by @chaoming0625 in #232
- update docs by @chaoming0625 in #233
- unify
brainpy.layers
with other modules inbrainpy.dyn
by @chaoming0625 in #234 - fix bugs by @chaoming0625 in #235
- update apis, docs, examples and others by @chaoming0625 in #236
- fixes by @chaoming0625 in #237
- fix: add dtype promotion = standard by @ztqakita in #239
- updates by @chaoming0625 in #240
- update training docs by @chaoming0625 in #241
- change doc path/organization by @chaoming0625 in #242
- Update advanced docs by @chaoming0625 in #243
- update quickstart docs & enable jit error checking by @chaoming0625 in #244
- update apis and examples by @chaoming0625 in #245
- update apis and tests by @chaoming0625 in #246
- Docs update and bugs fixed by @ztqakita in #247
- version 2.2.0 by @chaoming0625 in #248
- add norm and pooling & fix bugs in operators by @ztqakita in #249
Full Changelog: V2.1.12...V2.2.0
Version 2.1.12
Highlights
This release is excellent. We have made important improvements.
- We provide dozens of random sampling in NumPy which are not supportted in JAX, such as
brainpy.math.random.bernoulli
,
brainpy.math.random.lognormal
,brainpy.math.random.binomial
,brainpy.math.random.chisquare
,brainpy.math.random.dirichlet
,brainpy.math.random.geometric
,brainpy.math.random.f
,brainpy.math.random.hypergeometric
,brainpy.math.random.logseries
,brainpy.math.random.multinomial
,brainpy.math.random.multivariate_normal
,brainpy.math.random.negative_binomial
,brainpy.math.random.noncentral_chisquare
,brainpy.math.random.noncentral_f
,brainpy.math.random.power
,brainpy.math.random.rayleigh
,brainpy.math.random.triangular
,brainpy.math.random.vonmises
,brainpy.math.random.wald
,brainpy.math.random.weibull
- make efficient checking on numerical values. Instead of direct
id_tap()
checking which has large overhead, currentlybrainpy.tools.check_erro_in_jit()
is highly efficient. - Fix
JaxArray
operator errors onNone
- improve oo-to-function transformation speeds
io
works:.save_states()
and.load_states()
What's Changed
- support dtype setting in array interchange functions by @chaoming0625 in #209
- fix #144: operations on None raise errors by @chaoming0625 in #210
- add tests and new functions for random sampling by @c-xy17 in #213
- feat: fix
io
for brainpy.Base by @chaoming0625 in #211 - update advanced tutorial documentation by @chaoming0625 in #212
- fix #149 (dozens of random samplings in NumPy) and fix JaxArray op errors by @chaoming0625 in #216
- feat: efficient checking on numerical values by @chaoming0625 in #217
Full Changelog: V2.1.11...V2.1.12