CarloLucibello / GraphNeuralNetworks.jl

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

GNNGraph with multiple edge features not working #243

Closed chrisn-pik closed 1 year ago

chrisn-pik commented 1 year ago

Using one feature per edge is possible, e.g.

s = [1,1,2,3]
t = [2,3,1,1]
w = [1.1, 0.1, 2.3, 0.5]
g = GNNGraph(s, t, w)

However, I cannot find a way to use multiple features per edge, e.g.

w2 = [w, w]
g2 = GNNGraph(s, t, w2)

w2 is only a toy example. Several datasets have edges with multiple features, so this would be an important feature for several applications.

CarloLucibello commented 1 year ago

We distinguish edge weights, which are a single set of scalar numbers, from edge features. For instance here I create edge weights and two edge features array:

s = [1,1,2,3]
t = [2,3,1,1]
w = Float32[1.1, 0.1, 2.3, 0.5]
a = rand(Float32, 1, 4)     # edge features of dimension 1       
b = rand(Float32, 10, 4)  # edge features of dimension 10
g = GNNGraph(s, t, w, edata=(; a, b))

# access with
g.edata.a

# some other alternatives:
g = GNNGraph(s, t, edata=a)
# e is the default name when no one is provided
g.edata.e