fix(dyn): PoissonGroup never spikes due to boolean rand_like dtype#862
Merged
Conversation
PoissonGroup.update drew random values with rand_like(self.spike.value). Since spike is boolean-typed and rand_like inherits the input dtype, the draw was boolean (approximately all True), so the spike-probability comparison was always False and the group never fired. This silenced every network driven by PoissonGroup, including the decision_making_network and stdp simulation examples. Force a real uniform draw with dtype=float. Add firing-rate regression tests (default and batching mode); the previous shape-only test missed this.
Reviewer's GuideFixes PoissonGroup so it actually emits spikes by forcing the random draw to use a float dtype, and adds regression tests that verify both firing rate and batched behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Problem
PoissonGroupnever emitted spikes. InPoissonGroup.update, the random draw usedrand_like(self.spike.value). Sincespikeis boolean-typed andrand_likeinherits theinput dtype, the draw was boolean (≈ all
True), so the comparisonTrue <= probwas alwaysFalseand the group never fired.Because both
examples/dynamics_simulation/decision_making_network.pyandexamples/dynamics_simulation/stdp.pyare driven entirely byPoissonGroup, the decisionnetwork was silent (0 Hz in every population) and STDP weights stayed frozen.
Fix
Force a real uniform draw with
dtype=float:Tests
The existing
test_PoissonGrouponly asserted output shape, which is why the regressionslipped through. Added:
test_PoissonGroup_fires_at_expected_rate— asserts empirical rate ≈freqs(0 Hz on old code).test_PoissonGroup_fires_in_batching_mode— covers batched shape preservation + rate.Verification
input_test.py+STDP_test.py: 139 passed.max|ΔW|over 10 s = 0.0032 (weights now evolve).Summary by Sourcery
Ensure PoissonGroup emits spikes by fixing its random draw dtype and strengthen tests to verify firing rates, including in batching mode.
Bug Fixes:
Tests: