Repository navigation
reset_parameters for every model; all-models initialization test - #1452
Merged
bruAristimunha merged 2 commits intoOct 17, 2026
Merged
bruAristimunha merged 2 commits into
bruAristimunha merged 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1452 +/- ##
==========================================
+ Coverage 91.00% 91.04% +0.03%
==========================================
Files 165 165
Lines 21562 21655 +93
==========================================
+ Hits 19622 19715 +93
Misses 1940 1940 🚀 New features to boost your workflow:
|
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.
Part of #1442.
EEGModuleMixin.reset_parameters()draws new initial weights with the model's own scheme: every layer and block is reset (reset_parameters/_reset_parameters, children first), then the model's_init_parameters()runs. Each model's initialization now lives in_init_parameters()(the constructor and the reset both call it) or, for blocks that initialize as they are built (ATCNet, AXON, BENDR, EEGPT, MAPA, MEDFormer, SignalJEPA, STEEGFormer, the PBT encoder), in that block'sreset_parameters.test_model_init.py, over all 85 registered models:reset_parameters()every parameter has the constructor's distribution (std within ±15 %; constant tensors such as zero biases stay constant);_init_parameters()is not a no-op.Before the per-model hooks, 37 models drew other weights on reset (lost zero biases, PyTorch defaults instead of Xavier/truncated normal, …); all pass now (168).
Construction unchanged: all 85 models built with the same seed on master and here have bit-identical initial weights (10,480 tensors).
init_weights_now skips lazy layers, as PyTorch's own reset does (CBraMod's lazy head).PBT: its encoder's GPT-2
proj.weightscaling is overwritten by PBT's own init, exactly as in the reference implementation (src/model.py: the encoder scales, thenPBT.__init__applies_init_weightsto every Linear). It is kept and documented, because dropping the draw would change PBT's weights.