Skip to content

Commit

Permalink
Merge pull request #170 from chaoming0625/master
Browse files Browse the repository at this point in the history
synapse models support heterogeneuos weights
  • Loading branch information
chaoming0625 authored Apr 19, 2022
2 parents efb7bb7 + a6e61fc commit 907435a
Show file tree
Hide file tree
Showing 5 changed files with 492 additions and 360 deletions.
17 changes: 12 additions & 5 deletions brainpy/dyn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,16 +483,19 @@ def register_delay(
def get_delay(
self,
name: str,
delay_step: Union[int, bm.JaxArray, bm.ndarray]
delay_step: Union[int, bm.JaxArray, bm.ndarray],
indices=None,
):
"""Get delay data according to the delay times.
"""Get delay data according to the provided delay steps.
Parameters
----------
name: str
The delay variable name.
delay_step: int, JaxArray, ndarray
The delay length.
indices: optional, JaxArray, ndarray
The indices of the delay.
Returns
-------
Expand All @@ -501,14 +504,18 @@ def get_delay(
"""
if name in self.global_delay_vars:
if isinstance(delay_step, int):
return self.global_delay_vars[name](delay_step)
return self.global_delay_vars[name](delay_step, indices)
else:
return self.global_delay_vars[name](delay_step, jnp.arange(delay_step.size))
if indices is None:
indices = jnp.arange(delay_step.size)
return self.global_delay_vars[name](delay_step, indices)
elif name in self.local_delay_vars:
if isinstance(delay_step, int):
return self.local_delay_vars[name](delay_step)
else:
return self.local_delay_vars[name](delay_step, jnp.arange(delay_step.size))
if indices is None:
indices = jnp.arange(delay_step.size)
return self.local_delay_vars[name](delay_step, indices)
else:
raise ValueError(f'{name} is not defined in delay variables.')

Expand Down
Loading

0 comments on commit 907435a

Please sign in to comment.