Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Entries link to the pull request that introduced them.

**Fixed**
- `GNNChain` now returns its state with the same structure it receives, `(; layers = (; layer_1, ...))`, as the Lux layer interface requires. It previously returned the per-layer states without the `layers` wrapper, so feeding the returned state back into the chain (as `Lux.Training.single_train_step!` does) failed with a `FieldError`. This is breaking for code that worked around the bug by re-wrapping the state as `(; layers = st)`, as the docs examples did: drop the wrapper.
- `NNConv` now returns its state as `(; nn = ...)`, the same structure it receives. It previously returned the inner network's state without the `nn` wrapper, so passing the returned state back into the layer (e.g. on the second step of `Lux.Training.single_train_step!`) failed with a `FieldError` ([#728]).

## GNNlib.jl — Unreleased (towards 1.4.1)

Expand Down Expand Up @@ -247,4 +248,5 @@ Lux implementations of the graph convolutional, pooling, and temporal layers
[#706]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/706
[#722]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/722
[#718]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/718
[#728]: https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/pull/728
[FluxML/Zygote.jl#1662]: https://github.com/FluxML/Zygote.jl/issues/1662
2 changes: 1 addition & 1 deletion GNNLux/src/layers/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ function (l::NNConv)(g, x, e, ps, st)
nn = StatefulLuxLayer{true}(l.nn, ps.nn, st.nn)
m = (; nn, l.aggr, ps.weight, bias = _getbias(ps), l.σ)
y = GNNlib.nn_conv(m, g, x, e)
stnew = _getstate(nn)
stnew = (; nn = _getstate(nn))
return y, stnew
end

Expand Down
11 changes: 11 additions & 0 deletions GNNLux/test/layers/conv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@
x = randn(Float32, n_in, g2.num_nodes)
e = randn(Float32, n_in_edge, g2.num_edges)
test_lux_layer(rng, l, g2, x; outputsize=(n_out,), e, container=true)

# The returned state has the same structure as the input state,
# so it can be fed back into the layer (as in a training loop).
nn = Chain(Dense(n_in_edge => n_out * n_in), BatchNorm(n_out * n_in))
l = NNConv(n_in => n_out, nn, tanh, aggr = +)
ps, st = LuxCore.setup(rng, l)
y, st′ = l(g2, x, e, ps, st)
@test typeof(st′) == typeof(st)
@test st′.nn.layer_2.running_mean != st.nn.layer_2.running_mean
y′, st″ = l(g2, x, e, ps, st′)
@test typeof(st″) == typeof(st)
end

@testset "GMMConv" begin
Expand Down
Loading