CarloLucibello / GraphNeuralNetworks.jl

Graph Neural Networks in Julia
https://carlolucibello.github.io/GraphNeuralNetworks.jl/dev/
MIT License
209 stars 47 forks source link

Add SAGEConv support to HeteroGraphConv #384

Closed rbSparky closed 4 months ago

rbSparky commented 4 months ago

Covers Issue #311

Will check tests

rbSparky commented 4 months ago

test fails, fixing

rbSparky commented 4 months ago

Resolved below issue, ignore (version issues)

when I test locally even with just 

@testset "HeteroGraphConv" begin
    d, n = 3, 5
    g = rand_bipartite_heterograph(n, 2*n, 15)
    hg = rand_bipartite_heterograph((2,3), 6)

    model = HeteroGraphConv([(:A,:to,:B) => GraphConv(d => d), 
                            (:B,:to,:A) => GraphConv(d => d)])

    @testset "CGConv" begin
        x = (A = rand(Float32, 4,2), B = rand(Float32, 4, 3))
        layers = HeteroGraphConv( (:A, :to, :B) => CGConv(4 => 2, relu),
                                    (:B, :to, :A) => CGConv(4 => 2, relu));
        y = layers(hg, x); 
        @test size(y.A) == (2,2) && size(y.B) == (2,3)
    end
end

in the `test/layers/heteroconv.jl` file, tests still fail locally while they pass when I push them to github (like above, this current test which passes here fails locally for me)

error message:

[ Info: Testing graph format :coo
CGConv: Error During Test at \path\GraphNeuralNetworks.jl\test\layers\heteroconv.jl:32
  Got exception outside of a @test
  MethodError: no method matching (::CGConv{Dense{typeof(σ), Matrix{Float32}, Vector{Float32}}, Dense{typeof(relu), Matrix{Float32}, Vector{Float32}}})(::GNNHeteroGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}, ::Tuple{Matrix{Float32}, Matrix{Float32}})
  Closest candidates are:
    (::GNNLayer)(::AbstractVector{<:GNNGraph}, ::Any...; kws...) at C:\Users\[user]\.julia\packages\GraphNeuralNetworks\HVWUc\src\layers\basic.jl:14

Please let me know if you know why this happens.

Thanks
rbSparky commented 4 months ago

Layer requires more changes to be made suitable for heterogeneous graphs Working on it

edit: done

rbSparky commented 4 months ago

Tests should work now (edit: they do)

rbSparky commented 4 months ago

Ready for merge?