Object-oriented Transformations#

The math module for whole BrainPy ecosystem. This module provides basic mathematical operations, including:

  • numpy-like array operations

  • linear algebra functions

  • random sampling functions

  • discrete fourier transform functions

  • just-in-time compilation for class objects

  • automatic differentiation for class objects

  • dedicated operators for brain dynamics modeling

  • activation functions

  • device/dtype switching

  • and others

Details in the following.

Objects and Variables#

BrainPyObject

The BrainPyObject class for the whole BrainPy ecosystem.

FunAsObject

Transform a Python function as a BrainPyObject.

Partial

A picklable, object-aware partial application of a function.

NodeList

A sequence of BrainPyObject, which is compatible with vars() and nodes() operations in a BrainPyObject.

NodeDict

A dictionary of BrainPyObject, which is compatible with vars() operation in a BrainPyObject.

node_dict

node_list

Variable

The pointer to specify the dynamical variable.

Parameter

The pointer to specify the parameter.

TrainVar

The pointer to specify the trainable variable.

VariableView

A view of a Variable instance.

VarList

A sequence of Variable, which is compatible with vars() operation in a BrainPyObject.

VarDict

A dictionary of Variable, which is compatible with vars() operation in a BrainPyObject.

var_list

var_dict

Object-oriented Transformations#

grad

Automatic gradient computation for functions or class objects.

vector_grad

Take vector-valued gradients for function func.

jacobian

Extending automatic Jacobian (reverse-mode) of func to classes.

jacrev

Extending automatic Jacobian (reverse-mode) of func to classes.

jacfwd

Extending automatic Jacobian (forward-mode) of func to classes.

hessian

Hessian of func as a dense array.

cond

Simple conditional statement (if-else) with instance of Variable.

ifelse

If-else control flows looks like native Pythonic programming.

for_loop

for-loop control flow with Variable.

while_loop

while-loop control flow with Variable.

scan

scan control flow with Variable.

jit

JIT (Just-In-Time) compilation for BrainPy computation.

cls_jit

Just-in-time compile a function and then the jitted function as the bound method for a class.

to_object

Transform a Python function to BrainPyObject.

function

Transform a Python function into a BrainPyObject.

ProgressBar

A progress bar for tracking the progress of a jitted for-loop computation.

Helpers for Object-oriented Transformations#