fix: correct LSO surrogate, add missing @staticmethod, fix __layer__ string concat#418
Open
haoyu-haoyu wants to merge 1 commit intojeshraghian:masterfrom
Open
fix: correct LSO surrogate, add missing @staticmethod, fix __layer__ string concat#418haoyu-haoyu wants to merge 1 commit intojeshraghian:masterfrom
haoyu-haoyu wants to merge 1 commit intojeshraghian:masterfrom
Conversation
…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"`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
LSO()surrogate function (issue snntorch.surrogate.LSO returns StochasticSpikeOperator instead of LeakySpikeOperator #347): was callingStochasticSpikeOperator.apply(x, slope)instead ofLeakySpikeOperator.apply(x, slope).StochasticSpikeOperatorexpects 3 arguments (input, mean, variance) butLSOonly passes 2 (input, slope), causing aTypeErrorat runtime.Add missing
@staticmethodtoSpikeRateEscape.backwardinsurrogate.py. Theforwardmethod at line ~353 correctly has@staticmethod, butbackwardat line ~361 is missing it. Without it, PyTorch autograd will passselfas 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 toLeakySpikeOperatorwhich accepts (input, slope)SpikeRateEscape.backwardnow matches PyTorch'storch.autograd.Functionconvention__layer__list now correctly contains 3 separate strings