Skip to content

Commit

Permalink
Merge pull request #413 from dkjshk/master
Browse files Browse the repository at this point in the history
Fix bug for piecewise_leaky_relu
  • Loading branch information
fangwei123456 committed Aug 25, 2023
2 parents 074bf58 + 515fa04 commit ca141ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spikingjelly/activation_based/surrogate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def backward(grad_output, x, alpha):
def piecewise_leaky_relu_backward(grad_output: torch.Tensor, x: torch.Tensor, w: float, c: float):
mask_width = (x.abs() < w)
mask_c = mask_width.logical_not()
return grad_output * x.masked_fill(mask_width, 1 / w).masked_fill(mask_c, c), None, None
return grad_output * x.masked_fill(mask_width, 1 / (2*w)).masked_fill(mask_c, c), None, None


class piecewise_leaky_relu(torch.autograd.Function):
Expand Down

0 comments on commit ca141ed

Please sign in to comment.