Skip to content

Example of having different types of edges #104

Discussion options

You must be logged in to vote

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.
Cheers

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by danielegrattarola
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #104 on December 09, 2020 18:12.