MCPcopy Create free account
hub / github.com/Intelligent-Computing-Lab-Panda/NDA_SNN / LIFSpike

Class LIFSpike

models/layers.py:53–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53class LIFSpike(nn.Module):
54 def __init__(self, thresh=0.5, tau=0.25, gamma=1.0):
55 super(LIFSpike, self).__init__()
56 self.thresh = thresh
57 self.tau = tau
58 self.gamma = gamma
59
60 def forward(self, x):
61 mem = torch.zeros_like(x[:, 0])
62 spikes = []
63 T = x.shape[1]
64 for t in range(T):
65 mem = mem * self.tau + x[:, t, ...]
66 spike = fire_function(self.gamma)(mem - self.thresh)
67 mem = (1 - spike) * mem
68 spikes.append(spike)
69 return torch.stack(spikes, dim=1)
70
71
72def add_dimention(x, T):

Callers 1

make_layersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected