I wanna get the loss weighted by the path length between the negative node and the positive node (maybe the sampling weight also generate by this) in a hierarchical graph.
Dose DGL provide graph API for this usage?
I wanna get the loss weighted by the path length between the negative node and the positive node (maybe the sampling weight also generate by this) in a hierarchical graph.
Dose DGL provide graph API for this usage?
You could implement single-source-shortest-path using message passing:
g.ndata['x'] = torch.zeros(g.num_nodes())
g.ndata['x'][:] = 1000000 # very big number
g.ndata['x'][source] = 0
for _ in range(graph_diameter):
g.update_all(fn.u_add_e(βxβ, βdistanceβ, βmβ), fn.min(βmβ, βcβ))
g.ndata[βxβ] = torch.min(g.ndata[βxβ], g.ndata[βcβ])
If you have multiple sources you can parallelize similarly. Note that this will give you a num_sources x num_nodes
distance tensor.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.