Update Both Edge & Node Features

Hello everyone,

Like in the first section of https://docs.dgl.ai/guide/message.html , I would like to update both edges and nodes features per step.
I was wondering how I could do it using DGL:

def edge_message_func(edges):
    return {'me': phi(edges.src['h'], edges.dst['h'], edges.data['e'])}
 
def reduce_func(nodes):
    return {'h': rho(nodes.mailbox['me'])}

def apply_func(nodes):
    return {'h': psi(nodes.data['h']}

Does that make sense?

Thanks.

This looks fine to me.

Is there an easy way to integrate the edge features consideration for unsupervised GraphSAGE?

Can’t you simply define a message function like below?

def edge_message_func(edges):
    return {'me': torch.cat([edges.src['h'], edges.data['e']], dim=1)}