Skip to content
Merged

Math #563

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions brainpy/_src/dynold/neurons/reduced_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def __init__(
self.integral = sdeint(method=self.method, f=self.derivative, g=self.noise)
self.reset_state(self.mode)

def reset_state(self, batch_size=None):
def reset_state(self, batch_size=None, **kwargs):
super().reset_state(batch_size)
if self.input_var:
self.input = variable_(bm.zeros, self.varshape, batch_size)
Expand Down Expand Up @@ -1023,7 +1023,7 @@ def __init__(

# parameters for training
mode: bm.Mode = None,
spike_fun: Callable = bm.surrogate.inv_square_grad,
spike_fun: Callable = bm.surrogate.inv_square_grad2,
):
# initialization
super(HindmarshRose, self).__init__(size=size,
Expand Down
8 changes: 7 additions & 1 deletion brainpy/_src/math/interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@


__all__ = [
'as_device_array', 'as_jax', 'as_ndarray', 'as_numpy', 'as_variable',
'as_device_array', 'as_jax', 'as_ndarray', 'as_numpy', 'as_variable', 'is_bp_array'
]


def _as_jax_array_(obj):
return obj.value if isinstance(obj, Array) else obj


def is_bp_array(x):
"""Check if the input is a ``brainpy.math.Array``.
"""
return isinstance(x, Array)


def as_device_array(tensor, dtype=None):
"""Convert the input to a ``jax.numpy.DeviceArray``.

Expand Down
2 changes: 1 addition & 1 deletion brainpy/_src/math/surrogate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


from .base import *
from ._one_input import *
from ._one_input_new import *
from ._two_inputs import *
Loading