Example of having different types of edges #104
-
Is there any example of applying a GNN model on a graph that has different types of edges? I'm experimenting with applying GNN models in order to find similar graphs. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi, You are correct, edge types are interpreted as edge attributes in Spektral. You can have a look at the examples on molecules here for a template to start. For your problem, one possible way would be to have a graph embedding function like so: conv = EdgeConditionedConv(32, activation='relu')
pool = GlobalSumPool()
def embed(x, a, e):
x = conv([x, a, e])
z = pool(x)
return z[0] and then: # Dummy values
a = np.ones((10, 10))
x = np.ones((10, 3))
e = np.ones((10 * 10, 4))
graph_1 = (x, a, e)
graph_2 = (x, a, e)
# Compute similarity
z1 = embed(*graph_1)
z2 = embed(*graph_2)
sim = tf.reduce_sum(z1 * z2) Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your useful reply. |
Beta Was this translation helpful? Give feedback.
-
That is a setting of heterogeneous edge attributes which is not yet supported in Spektral.
|
Beta Was this translation helpful? Give feedback.
Hi,
You are correct, edge types are interpreted as edge attributes in Spektral. You can have a look at the examples on molecules here for a template to start.
For your problem, one possible way would be to have a graph embedding function like so:
and then:
Hope this helps.
Cheers