Replace the network-wide init scheme with per-parameter initializers - #85
Merged
jessegrabowski merged 3 commits intoAug 11, 2026
Merged
Conversation
Every parameter now declares the law it is drawn from, so `initialize` means redraw from those declarations under one seed. Linear and Embedding could not declare their own default while a scheme existed, since a declaration shadowed it -- that trap, the refusal of a constant scheme, and the three-way precedence all go with it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
==========================================
- Coverage 95.49% 95.48% -0.01%
==========================================
Files 45 45
Lines 1819 1818 -1
==========================================
- Hits 1737 1736 -1
Misses 82 82 ☔ View full report in Codecov by Harness. 🚀 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.
initialize_paramsandModel.initializetakeinitializers={parameter: HeNormal()}, keyed by the parameter object rather than its name, which is the only way to reach something no constructor keyword exposes — a bias inside a transformer block, or a weight in a network you loaded rather than built.Then
scheme=goes. It was the one API that acted on parameters the caller hadn't named, and it was paying for itself with everything around it:Linear.Whad to withhold its own default so a scheme could reach it, which made a recorded declaration a silent library-wide breakage; a constant had to be fenced off from it; precedence had to be three-way. All of that is gone, andLinearandEmbeddingnow declare the Xavier draw they were already using.initialize(seed=0)means redraw every parameter from its own initializer.One behavior change worth a look: a parameter that declares no initializer now raises rather than being silently left alone. Only reachable by building a
trainable()by hand — every layer declares one per parameter — but leaving it alone would put an all-zero weight back in a graph that trains, which is what #84 just fixed.Also worth knowing:
he_normalacross a whole network is now unsayable, and permanently, since onceWdeclares there is no set of undeclared weights left to address. Per-layerweight_initializer=is the replacement, as in torch, flax and keras.