Skip to content

Let parameters declare their own initializer - #70

Merged
jessegrabowski merged 4 commits into
pymc-devs:mainfrom
jessegrabowski:fix-batchnorm-init
Aug 9, 2026
Merged

Let parameters declare their own initializer#70
jessegrabowski merged 4 commits into
pymc-devs:mainfrom
jessegrabowski:fix-batchnorm-init

Conversation

@jessegrabowski

Copy link
Copy Markdown
Member

Model.initialize mapped one scheme over every trainable parameter, so xavier_normal replaced batch norm's unit scale and zero shift with random draws — the layer then starts by scaling activations toward zero, sign flips included, and trains anyway, just worse. Bias vectors got the same treatment from a fan-based formula that means nothing for a 1-D vector. Parameters can now declare an initializer that a network-wide scheme leaves alone.

@codecov-commenter

codecov-commenter commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.71%. Comparing base (8eeb3a0) to head (fa704eb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
+ Coverage   93.67%   93.71%   +0.04%     
==========================================
  Files          45       45              
  Lines        1770     1783      +13     
==========================================
+ Hits         1658     1671      +13     
  Misses        112      112              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jessegrabowski jessegrabowski added enhancement New feature or request layer New or improvement to existing LayerOp labels Aug 9, 2026
@jessegrabowski
jessegrabowski merged commit 532a0c8 into pymc-devs:main Aug 9, 2026
7 checks passed
jessegrabowski added a commit that referenced this pull request Aug 10, 2026
* Assert each layer declares the initializers its parameters need

Passes as written: it pins the behavior gh #70 established so the initializer keywords landing next cannot quietly strip a declaration, which is the one way they break something.

* Add a normal initializer

Its two arguments both default, which is what lets it into a registry whose entries are built with no arguments; a differently parameterized initializer can only be passed as an instance.

* Let Linear take its weight and bias initializers

* Let Embedding take its weight initializer

* Let the norm layers take their affine initializers

* Cite Glorot and Bengio on the Xavier initializers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request layer New or improvement to existing LayerOp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants