Skip to content

fix: correct LSO surrogate, add missing @staticmethod, fix __layer__ string concat#418

Open
haoyu-haoyu wants to merge 1 commit intojeshraghian:masterfrom
haoyu-haoyu:fix/surrogate-and-layer-bugs
Open

fix: correct LSO surrogate, add missing @staticmethod, fix __layer__ string concat#418
haoyu-haoyu wants to merge 1 commit intojeshraghian:masterfrom
haoyu-haoyu:fix/surrogate-and-layer-bugs

Conversation

@haoyu-haoyu
Copy link
Copy Markdown

Summary

  • Fix LSO() surrogate function (issue snntorch.surrogate.LSO returns StochasticSpikeOperator instead of LeakySpikeOperator #347): was calling StochasticSpikeOperator.apply(x, slope) instead of LeakySpikeOperator.apply(x, slope). StochasticSpikeOperator expects 3 arguments (input, mean, variance) but LSO only passes 2 (input, slope), causing a TypeError at runtime.

  • Add missing @staticmethod to SpikeRateEscape.backward in surrogate.py. The forward method at line ~353 correctly has @staticmethod, but backward at line ~361 is missing it. Without it, PyTorch autograd will pass self as the first argument instead of the context object.

  • Add missing comma between "BatchNormTT2d" and "GradedSpikes" in _layers/__init__.py. Adjacent string literals without a comma causes Python to concatenate them into "BatchNormTT2dGradedSpikes".

Test plan

  • LSO() now correctly dispatches to LeakySpikeOperator which accepts (input, slope)
  • SpikeRateEscape.backward now matches PyTorch's torch.autograd.Function convention
  • __layer__ list now correctly contains 3 separate strings

…tring concat

- Fix `LSO()` to call `LeakySpikeOperator.apply()` instead of
  `StochasticSpikeOperator.apply()` (issue jeshraghian#347). The wrong class
  expects 3 args (input, mean, variance) but LSO only passes 2
  (input, slope), causing a TypeError at runtime.

- Add missing `@staticmethod` decorator to `SpikeRateEscape.backward`.
  Every other backward method in the file has this decorator; without
  it, PyTorch autograd passes `self` instead of the saved context.

- Add missing comma between `"BatchNormTT2d"` and `"GradedSpikes"` in
  `_layers/__init__.py`. Without it, Python string concatenation
  produces `"BatchNormTT2dGradedSpikes"`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant