Dropping edges before message pass

Hi, I wanted for each convolution to randomly ignore N edges. I guess that this would be equivalent to doing torch.nn.Dropout on the adjacency matrix. If i had to do it without DGL API, I would do something like below to drop half of the edges:

drop_edge_rate = 0.5
n_edges = len(h['edges'][0])
dropedge_filter = torch.randperm(n_edges, device = device)[:int(n_edges*drop_edge_rate)]

selected_eIDs_0 = h['edges'][0].index_select(dim = 0, index = dropedge_filter)
selected_eIDs_1 = h['edges'][1].index_select(dim = 0, index = dropedge_filter)

new_temporary_edges = torch.stack([selected_eIDs_0, selected_eIDs_1], dim = 1)

How can I drop the edges per convolution and still use DGL API’s like: g.update_all(fn.copy_u('x', 'm'), fn.sum('m', 'h')) or edge_softmax? Thanks!!

Since 0.8, we now provide several transform modules that can be applied to built-in DGL datasets as described in the “Graph Dataset and Transforms” section here. The transform module DropEdge can meet your requirement.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.