Own the NamedTuple conversion, closing D9 - #9
Merged
Merged
Conversation
`Base.NamedTuple(p::NetworkParameters) = params(p)` was the one line of Phase 1 work `PLAN.md` recorded as missing. Without it a downstream that needs to turn a parameter set back into a plain `NamedTuple` has to define the method itself, and owns neither `Base`'s constructor nor the type — which is what GeometricMachineLearning #207 had to do to write a nested parameter set to HDF5. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Phase 2 is up, and depends on this: AbstractNeuralNetworks#33 takes the parameter container from here, with SymbolicNeuralNetworks#50, GeometricMachineLearning#246 and NonlinearIntegrators#86 following it. |
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.
PLAN.md§4 listed D9 as "one line of Phase 1 work that is not there yet":src/parameters.jlforwardedkeys,values,getindexandpairs, and hadparams, but noBase.NamedTuple(p::NetworkParameters).Without it, a downstream that needs to turn a parameter set back into a plain
NamedTuplehas to define the method itself — and owns neitherBase'sconstructor nor the type, so the method is piracy on both counts. That is exactly
what GeometricMachineLearning #207
had to do (
GML/src/layers/forcing_dissipation_layers.jl) to write a nestedparameter set to HDF5.
Changes
src/parameters.jl:Base.NamedTuple(p::NetworkParameters) = params(p).test/parameters_tests.jl: a testset covering the conversion, that it agreeswith
params, and the round trip back throughNetworkParameters.docs/src/representations.md: mention the conversion where the other forwardedmethods are listed, with the reason it lives here.
PLAN.md: D9 moves to "1, fixed".Verification
Both clean. This PR is independent of the rest of Phase 2 and can go in on its own;
Phase 2 in
AbstractNeuralNetworksis what makes the conversion reachable throughthe
NeuralNetworkParametersalias.