JuliaGraphs / GraphNeuralNetworks.jl

Graph Neural Networks in Julia
https://juliagraphs.org/GraphNeuralNetworks.jl/graphneuralnetworks/
MIT License
229 stars 45 forks source link

Example given for `GNNGraph` results in error #380

Closed rbSparky closed 9 months ago

rbSparky commented 9 months ago

Given example:

using Flux, GraphNeuralNetworks, CUDA

data = [[2,3], [1,4,5], [1], [2,5], [2,4]]
g = GNNGraph(data)

g.num_nodes  # 5
g.num_edges  # 10
g.num_graphs # 1

s = [1,1,2,2,2,3,4,4,5,5]
t = [2,3,1,4,5,3,2,5,2,4]
g = GNNGraph(s, t)

g = GNNGraph(erdos_renyi(100, 20))

g = GNNGraph(g, ndata = (x=rand(100, g.num_nodes), y=rand(g.num_nodes)))

g.edata.z = rand(16, g.num_edges)

g = GNNGraph(g, ndata = rand(100, g.num_nodes), edata = rand(16, g.num_edges))

g.ndata.x # or just g.x
g.ndata.e # or just g.e

gives error here:

g.ndata.x # works

g.x # works

g.e # works

g.ndata.e # ERROR: KeyError: key :e not found

Does some code need to be changed? If so, I could try that. If I am doing something wrong, please let me know.

Thanks

rbSparky commented 9 months ago

Full error:

ERROR: KeyError: key :e not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Any}, key::Symbol)
   @ Base .\dict.jl:481
 [2] getproperty(ds::DataStore, s::Symbol)
   @ GraphNeuralNetworks.GNNGraphs path\.julia\packages\GraphNeuralNetworks\HVWUc\src\GNNGraphs\datastore.jl:104
 [3] top-level scope
   @ path\conv.jl:1281
CarloLucibello commented 9 months ago

It should be g.edata.e instead of g.ndata.e. Is that example in the documentation? If so it should be fixed.

rbSparky commented 9 months ago

It should be g.edata.e instead of g.ndata.e. Is that example in the documentation? If so it should be fixed.

Yes, its in the docs

Made PR to fix