Repository navigation
Make zero-mean fn. constant a Static class - #500
Merged
Merged
Conversation
This was referenced Jul 26, 2026
thomaspinder
added a commit
that referenced
this pull request
Jul 26, 2026
`Zero()` was trainable and drifted towards the data mean during `fit` (0.0 -> 5.09 on a dataset with mean 5), contradicting its own docstring and silently changing the posterior mean of every model using the default mean function. Regression of #330, fixed once in #500. The cause is a changed trainability contract rather than a lost line. Under nnx, `fit` optimised only `Parameter` instances, so `Zero`'s bare array was inert by construction -- which is why #530 could drop the `Static` wrapper and stay correct. Under Equinox, `fit` partitions on `eqx.is_array`, making every array leaf trainable, and `Zero` was still relying on the old meaning of a bare array. Wrap the constant in `paramax.non_trainable` so the invariant holds by construction rather than by the ambient filter semantics. The guard for this was weakened rather than removed: #614 replaced `test_zero_mean_remains_zero` with a test of the initial value only, and `test_zero_mean_function_uses_raw_value` asserted the defect outright. Restore the end-to-end fit assertion and invert the unit test. Fixes #712 Claude-Session: https://claude.ai/code/session_01Bj9k5fnAZ8JzD4Rg3HMDMj Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Checklist
hatch run dev:formatbefore committing.Description
Set the
constantfield of the zero-mean function to be aStaticparameter to prevent its value being changed from zero during training.Issue Number: #499