Skip to content

Commit

Permalink
Delay Dense PyModel fix
Browse files Browse the repository at this point in the history
Signed-off-by: bamsumit <[email protected]>
  • Loading branch information
bamsumit committed Aug 4, 2023
1 parent 7ca35a5 commit 200b3cd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lava/proc/dense/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ def calc_act(self, s_in) -> np.ndarray:
# which is then transposed to get the activation matrix.
return np.reshape(
np.sum(self.get_delay_wgts_mat(self.weights,
self.delays) * s_in, axis=1),
(np.max(self.delays) + 1, self.weights.shape[0])).T
self.delays,
self.a_buff.shape[-1] - 1) * s_in,
axis=1),
(self.a_buff.shape[-1], self.weights.shape[0])).T

@staticmethod
def get_delay_wgts_mat(weights, delays) -> np.ndarray:
def get_delay_wgts_mat(weights, delays, max_delay) -> np.ndarray:
"""
Create a matrix where the synaptic weights are separated
by their corresponding delays. The first matrix contains all the
Expand All @@ -235,7 +237,7 @@ def get_delay_wgts_mat(weights, delays) -> np.ndarray:
"""
return np.vstack([
np.where(delays == k, weights, 0)
for k in range(np.max(delays) + 1)
for k in range(max_delay + 1)
])

def update_act(self, s_in):
Expand Down

0 comments on commit 200b3cd

Please sign in to comment.