Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fangwei123456 committed Apr 25, 2023
1 parent ecb69d0 commit 4f72264
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spikingjelly/activation_based/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,19 +1989,26 @@ def k(self, value: float):
self._k = value

def single_step_forward(self, x: torch.Tensor):
if self.k < 1.:
raise ValueError("The masked PSN can not work in single-step mode when k < 1!")

self.queue.append(x.flatten())
if self.queue.__len__() > self.order:
self.queue.pop(0)

if self.time_step + 1 > self.T:
raise OverflowError(f"The MaskedPSN(T={self.T}) has run {self.time_step + 1} time-steps!")

weight = self.masked_weight()[self.time_step][self.time_step + 1 - self.queue.__len__(): self.time_step + 1]

weight = self.masked_weight()[self.time_step, self.time_step + 1 - self.queue.__len__(): self.time_step + 1]
x_seq = torch.stack(self.queue)



for i in range(x.dim()):
weight = weight.unsqueeze(-1)


h = torch.sum(weight * x_seq, 0)
spike = self.surrogate_function(h + self.bias[self.time_step])

Expand Down

0 comments on commit 4f72264

Please sign in to comment.