THUDM / GRAND

Source code and dataset of the NeurIPS 2020 paper "Graph Random Neural Network for Semi-Supervised Learning on Graphs"
MIT License
206 stars 40 forks source link

About GRAND_DropEdge #3

Closed GNN-zl closed 3 years ago

GNN-zl commented 3 years ago

Hi, could you release the code of GRAND_DropEdge? I tried the code of Dropedge, but the result isn't satisfied. `def rand_prop_dropedge(adj_dropedge, features, training): if training: nnz = adj_dropedge.nnz perm = np.random.permutation(nnz) preserve_nnz = int(nnz * 0.5) perm = perm[:preserve_nnz] r_adj = sp.coo_matrix((adj_dropedge.data[perm], (adj_dropedge.row[perm], adj_dropedge.col[perm])), shape=adj_dropedge.shape)

    r_adj = r_adj + sp.eye(r_adj.shape[0])
    D1 = np.array(r_adj.sum(axis=1))
    D2 = np.array(r_adj.sum(axis=0))**(-0.5)
    D1 = sp.diags(D1[:,0], format='csr')
    D2 = sp.diags(D2[0,:], format='csr')
    A_dropedge = r_adj.dot(D1)
    A_dropedge = D2.dot(A_dropedge)
    A_dropedge = sparse_mx_to_torch_sparse_tensor(A_dropedge).cuda()
    features = propagate(features, A_dropedge, args.order)

else:
    features = propagate(features, A, args.order)

return features`

where adj_dropedge is from adj = nx.adjacency_matrix(nx.from_dict_of_lists(graph)) adj = adj + adj.T.multiply(adj.T > adj) - adj.multiply(adj.T > adj) adj_dropedge = adj adj_dropedge = sp.coo_matrix(adj_dropedge)

Thanks!

wzfhaha commented 3 years ago

Hi, we have uploaded the code of Grand_Dropedge to https://github.com/wzfhaha/grand_dropedge. Hope it will be helpful to you.