Skip to content

Commit 724bdc2

Browse files
authored
Add GINConv support to HeteroGraphConv (#390)
* Add GINConv support to HeteroGraphConv * gin hetero * trying tests * tests pass * tests pass * fix
1 parent 64b3cbb commit 724bdc2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/layers/conv.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,13 @@ Flux.trainable(l::GINConv) = (nn = l.nn,)
808808

809809
GINConv(nn, ϵ; aggr = +) = GINConv(nn, ϵ, aggr)
810810

811-
function (l::GINConv)(g::GNNGraph, x::AbstractMatrix)
811+
function (l::GINConv)(g::AbstractGNNGraph, x)
812812
check_num_nodes(g, x)
813-
m = propagate(copy_xj, g, l.aggr, xj = x)
814-
l.nn((1 + ofeltype(x, l.ϵ)) * x + m)
813+
xj, xi = expand_srcdst(g, x)
814+
815+
m = propagate(copy_xj, g, l.aggr, xj = xj)
816+
817+
l.nn((1 .+ ofeltype(xi, l.ϵ)) .* xi .+ m)
815818
end
816819

817820
function Base.show(io::IO, l::GINConv)

test/layers/heteroconv.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@
125125
@test size(y.A) == (2, 2) && size(y.B) == (2, 3)
126126
end
127127

128+
@testset "GINConv" begin
129+
x = (A = rand(4, 2), B = rand(4, 3))
130+
layers = HeteroGraphConv((:A, :to, :B) => GINConv(Dense(4, 2), 0.4),
131+
(:B, :to, :A) => GINConv(Dense(4, 2), 0.4));
132+
y = layers(hg, x);
133+
@test size(y.A) == (2, 2) && size(y.B) == (2, 3)
134+
end
135+
128136
@testset "ResGatedGraphConv" begin
129137
x = (A = rand(Float32, 4, 2), B = rand(Float32, 4, 3))
130138
layers = HeteroGraphConv((:A, :to, :B) => ResGatedGraphConv(4 => 2),

0 commit comments

Comments
 (0)