Object-oriented Transformations#

Objects and Variables#

BrainPyObject

The BrainPyObject class for the whole BrainPy ecosystem.

FunAsObject

Transform a Python function as a BrainPyObject.

Partial

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

alias of NodeDict

node_list

alias of NodeList

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

alias of VarList

var_dict

alias of VarDict

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.

make_loop

Make a for-loop function, which iterate over inputs.

make_while

Make a while-loop function.

make_cond

Make a condition (if-else) function.

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.

Helpers for Object-oriented Transformations#

eval_shape

Compute the shape/dtype of fun without any FLOPs.

VariableStack

Variable stack, for collecting all Variable used in the program.