Repository navigation
FIX Accept tensor inputs in amplitude attribution - #1464
Merged
bruAristimunha merged 1 commit intoOct 18, 2026
Merged
bruAristimunha merged 1 commit into
bruAristimunha merged 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1464 +/- ##
=======================================
Coverage 91.04% 91.04%
=======================================
Files 165 165
Lines 21653 21653
=======================================
Hits 19714 19714
Misses 1939 1939 🚀 New features to boost your workflow:
|
3 tasks done
bruAristimunha
approved these changes
Oct 18, 2026
bruAristimunha
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed: to_numpy before np.fft.rfft is the one-line fix; the CPU/CUDA × grad parametrization covers the documented inputs. Merging.
3 tasks done
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
amplitude_gradientsacceptstorch.Tensorinputs in its documented API, but passes them straight to NumPy FFT. CUDA tensors and tensors withrequires_grad=Trueraise before attribution runs.Changes
Convert through the existing
to_numpyhelper beforerfft. Add CPU/CUDA regressions with and without tracked input gradients, plus the changelog entry.Testing
Using Python 3.12, PyTorch 2.7.0+cu128 and NumPy 2.5.4:
pytest test/unit_tests/visualization -q: 34 passed, 1 skipped. Three added cases fail on unchanged master; the ordinary CPU-tensor control passes.pre-commit run --files braindecode/visualization/frequency.py test/unit_tests/visualization/test_gradients.py docs/whats_new.rst: all applicable hooks pass.Recorded PhysioNet EEG S001R04 with an analytic energy model and initialized
ShallowFBCSPNet, odd/even signal lengths, CPU and RTX 5070: all 24 input-form calls work, versus 12 failures before. All 12 previously working outputs stay byte-identical.Broad CPU/offline attempt (
pytest test/ -q --maxfail=3,HF_HUB_OFFLINE=1) on unchanged master and this branch gives the same 3 model-export failures, 1852 passes and 381 skips: LUNA pytree arity, TFMTokenizer/BrainTokenizersub(out=...)autograd errors. This is not a complete green suite.Regression tests cover the changed behavior
Style checks recorded
docs/whats_new.rstupdatedNotes for reviewers
The existing NumPy FFT and transfer to the model's device remain in place. The input tensor is detached for analysis; its
.gradremains unset. Checkpoint/reset_head/mixed-mode tests are N/A because no model definition or state handling changes.