Skip to content

Custom initializer not applied to the projection Dense in Flux GATConv, Flux GMMConv and GNNLux GMMConv #747

Backlog

Description

@CarloLucibello

Some layers accept an initializer (init in Flux, init_weight in GNNLux), documented as "Weights' initializer", but build their internal projection Dense without it. Only the other weights use the custom initializer, while the projection keeps the Dense default (glorot_uniform in Flux, kaiming_uniform in Lux):

GATv2Conv in both frontends already forwards the initializer to its Dense layers, and #741 does the same for GNNLux GATConv.

using GraphNeuralNetworks, Flux
l = GATConv(4 => 3; init = Flux.ones32)
all(==(1), l.a), all(==(1), l.dense_x.weight)          # (true, false)
l = GMMConv((4, 2) => 3; K = 2, init = Flux.ones32)
all(==(1), l.mu), all(==(1), l.dense_x.weight)         # (true, false)
using GNNLux, Lux, Random
ones_init(rng, d...) = ones(Float32, d...)
ps, st = Lux.setup(Xoshiro(0), GMMConv((4, 2) => 3; K = 2, init_weight = ones_init))
all(==(1), ps.mu), all(==(1), ps.dense_x.weight)       # (true, false)

(Julia 1.13.4, master at db9de27.)

Suggested fix: pass the initializer to these Dense constructors, e.g. Dense(in, out * heads; bias = false, init) in Flux and Dense(in => out * K; use_bias = false, init_weight) in GNNLux. This changes the default initialization of GNNLux GMMConv's projection from kaiming_uniform to glorot_uniform.

🧔‍♂️🤖 Assisted by Claude Sonnet 5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions