-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
I'm using GATConv inside a heterogeneous convolution layer:
function create_layer_hetero_conv(
dims::Pair;
activation = act,
)::HeteroGraphConv
HeteroGraphConv(
[
(src, edge, dst) => GATConv(dims.first => dims.second, activation) for
(src, edge, dst) in keys(EXAMPLE.edata)
];
aggr = (x, y) -> max.(x, y),
)
endIn my use case, some node types can have 0 nodes, and this led to
ERROR: LoadError: ArgumentError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
[1] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, ::Type{Int64})
@ Base ./reduce.jl:350
[2] _mapreduce
@ ./reduce.jl:421 [inlined]
[3] _mapreduce_dim
@ ./reducedim.jl:334 [inlined]
[4] mapreduce
@ ./reducedim.jl:326 [inlined]
[5] _maximum
@ ./reducedim.jl:984 [inlined]
[6] _maximum
@ ./reducedim.jl:983 [inlined]
[7] maximum
@ ./reducedim.jl:979 [inlined]
[8] maximum_dims
@ ~/.julia/packages/NNlib/1TYHL/src/utils.jl:72 [inlined]
[9] scatter(op::typeof(max), src::Array{Float32, 3}, idx::Vector{Int64}; init::Nothing, dstsize::Nothing)
@ NNlib ~/.julia/packages/NNlib/1TYHL/src/scatter.jl:179
[10] scatter
@ ~/.julia/packages/NNlib/1TYHL/src/scatter.jl:174 [inlined]
[11] softmax_edge_neighbors(g::GNNHeteroGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}, e::Array{Float32, 3})
@ GNNlib ~/.julia/packages/GNNlib/StdFP/src/utils.jl:93
[12] gat_conv(l::GATConv{Dense{typeof(identity), Matrix{Float32}, Bool}, Nothing, Float64, Float32, Matrix{Float32}, typeof(act), Vector{Float32}}, g::GNNHeteroGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}, x::Tuple{Matrix{Float32}, Matrix{Float32}}, e::Nothing)
@ GNNlib ~/.julia/packages/GNNlib/StdFP/src/layers/conv.jl:138
[13] GATConv
@ ~/.julia/packages/GraphNeuralNetworks/nauyk/src/layers/conv.jl:346 [inlined]
[14] (::GATConv{Dense{typeof(identity), Matrix{Float32}, Bool}, Nothing, Float64, Float32, Matrix{Float32}, typeof(act), Vector{Float32}})(g::GNNHeteroGraph{Tuple{Vector{Int64}, Vector{Int64}, Nothing}}, x::Tuple{Matrix{Float32}, Matrix{Float32}})
@ GraphNeuralNetworks ~/.julia/packages/GraphNeuralNetworks/nauyk/src/layers/conv.jl:346
[15] (::GraphNeuralNetworks.var"#forw#forw##0"{GNNHeteroGraph{Tuple{T, T, Union{Nothing, AbstractVector}} where T<:(AbstractVector{<:Integer})}, @NamedTuple{locus::Matrix{Float32}, constant::Matrix{Float32}, sort::Matrix{Float32}, literal::Matrix{Float32}, hole::Matrix{Float32}}})(l::GATConv{Dense{typeof(identity), Matrix{Float32}, Bool}, Nothing, Float64, Float32, Matrix{Float32}, typeof(act), Vector{Float32}}, et::Tuple{Symbol, Symbol, Symbol})
@ GraphNeuralNetworks ~/.julia/packages/GraphNeuralNetworks/nauyk/src/layers/heteroconv.jl:61
[16] #60
@ ./none:-1 [inlined]
[17] iterate
@ ./generator.jl:48 [inlined]
[18] collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{Vector{GATConv{Dense{typeof(identity), Matrix{Float32}, Bool}, Nothing, Float64, Float32, Matrix{Float32}, typeof(act), Vector{Float32}}}, Vector{Tuple{Symbol, Symbol, Symbol}}}}, GraphNeuralNetworks.var"#60#61"{GraphNeuralNetworks.var"#forw#forw##0"{GNNHeteroGraph{Tuple{T, T, Union{Nothing, AbstractVector}} where T<:(AbstractVector{<:Integer})}, @NamedTuple{locus::Matrix{Float32}, constant::Matrix{Float32}, sort::Matrix{Float32}, literal::Matrix{Float32}, hole::Matrix{Float32}}}}})
@ Base ./array.jl:790
[19] (::HeteroGraphConv)(g::GNNHeteroGraph{Tuple{T, T, Union{Nothing, AbstractVector}} where T<:(AbstractVector{<:Integer})}, x::@NamedTuple{locus::Matrix{Float32}, constant::Matrix{Float32}, sort::Matrix{Float32}, literal::Matrix{Float32}, hole::Matrix{Float32}})
@ GraphNeuralNetworks ~/.julia/packages/GraphNeuralNetworks/nauyk/src/layers/heteroconv.jl:63
How can I workaround this? The same problem doesn't occur if I just use GraphConv.
Metadata
Metadata
Assignees
Labels
No labels