Skip to content

Own the NamedTuple conversion, closing D9 - #9

Merged
michakraus merged 1 commit into
mainfrom
d9-namedtuple-conversion
Aug 21, 2026
Merged

michakraus merged 1 commit into
mainfrom
d9-namedtuple-conversion

Conversation

@michakraus

Copy link
Copy Markdown
Member

PLAN.md §4 listed D9 as "one line of Phase 1 work that is not there yet":
src/parameters.jl forwarded keys, values, getindex and pairs, and had
params, but no Base.NamedTuple(p::NetworkParameters).

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, 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 nested
parameter set to HDF5.

Changes

  • src/parameters.jl: Base.NamedTuple(p::NetworkParameters) = params(p).
  • test/parameters_tests.jl: a testset covering the conversion, that it agrees
    with params, and the round trip back through NetworkParameters.
  • docs/src/representations.md: mention the conversion where the other forwarded
    methods are listed, with the reason it lives here.
  • PLAN.md: D9 moves to "1, fixed".

Verification

julia --project -e 'using Pkg; Pkg.test()'    # 230 tests, was 226
julia --project=docs -e 'using Pkg; Pkg.develop(path="."); include("docs/make.jl")'

Both clean. This PR is independent of the rest of Phase 2 and can go in on its own;
Phase 2 in AbstractNeuralNetworks is what makes the conversion reachable through
the NeuralNetworkParameters alias.

`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>
Copilot AI lite review requested due to automatic review settings August 20, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@michakraus

Copy link
Copy Markdown
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.

@michakraus
michakraus merged commit ec0ce9b into main Aug 21, 2026
10 checks passed
@michakraus
michakraus deleted the d9-namedtuple-conversion branch August 21, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants