Skip to content

Version 2.2.0

Compare
Choose a tag to compare
@chaoming0625 chaoming0625 released this 29 Aug 10:25
· 1401 commits to master since this release
55f8301

This release has provided important improvements for BrainPy, including usability, speed, functions, and others.

Backwards Incompatible changes

  1. brainpy.nn module is no longer supported and has been removed since version 2.2.0. Instead, users should use brainpy.train module for the training of BP algorithms, online learning, or offline learning algorithms, and brainpy.algorithms module for online / offline training algorithms.
  2. 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

  1. brainpy.dyn.xxx (neurons) and brainpy.dyn.xxx (synapse) are no longer supported. Please use brainpy.neurons, brainpy.synapses modules.
  2. brainpy.running.monitor has been removed.
  3. brainpy.nn module has been removed.

New features

  1. brainpy.math.Variable receives a batch_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.
  1. brainpy.train provides brainpy.train.BPTT for back-propagation algorithms, brainpy.train.Onlinetrainer for online training algorithms, brainpy.train.OfflineTrainer for offline training algorithms.
  2. brainpy.Base class supports _excluded_vars setting to ignore variables when retrieving variables by using Base.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'])
  1. brainpy.analysis.SlowPointFinder supports directly analyzing an instance of brainpy.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})
  1. brainpy.datasets supports MNIST, FashionMNIST, and other datasets.
  2. 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)
  1. brainpy.layers module provides commonly used models for DNN and reservoir computing.
  2. Support composable definition of synaptic models by using TwoEndConn, SynOut, SynSTP and SynLTP.
>>> 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())
  1. 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
  2. Provide shortcuts for GPU memory management via brainpy.math.disable_gpu_memory_preallocation(), and brainpy.math.clear_buffer_memory().

What's Changed

Full Changelog: V2.1.12...V2.2.0