Variable

Variable#

class brainpy.math.Variable(value_or_size, dtype=None, batch_axis=None, *, axis_names=None)[source]#

The pointer to specify the dynamical variable.

Initializing an instance of Variable by two ways:

>>> import brainpy.math as bm
>>> # 1. init a Variable by the concreate data
>>> v1 = bm.Variable(bm.zeros(10))
>>> # 2. init a Variable by the data shape
>>> v2 = bm.Variable(10)

Note that when initializing a Variable by the data shape, all values in this Variable will be initialized as zeros.

Parameters:
  • value_or_size (Any) – The value or the size of the value.

  • dtype (type) – The type of the data.

  • batch_axis (int) – The batch axis.

  • axis_names (Optional[Sequence[str]]) – The name for each axis.

property value#

The data and its value.