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

Function fire_function

models/layers.py:34–50  ·  view source on GitHub ↗
(gamma)

Source from the content-addressed store, hash-verified

32
33
34def fire_function(gamma):
35 class ZIF(torch.autograd.Function):
36 @staticmethod
37 def forward(ctx, input):
38 out = (input >= 0).float()
39 ctx.save_for_backward(input)
40 return out
41
42 @staticmethod
43 def backward(ctx, grad_output):
44 (input, ) = ctx.saved_tensors
45 grad_input = grad_output.clone()
46 tmp = (input.abs() < gamma/2).float() / gamma
47 grad_input = grad_input * tmp
48 return grad_input, None
49
50 return ZIF.apply
51
52
53class LIFSpike(nn.Module):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected