Pytorch_geometric: How to train the adjacency (weight) matrix of the graph as a parameter?

Created on 8 Aug 2020  ·  4Comments  ·  Source: rusty1s/pytorch_geometric

❓ Questions & Help


The previous papers, including implementation, have already established graph structures. But suppose we have n sets of data {𝑥_𝑖,𝑦_𝑖 }_(𝑖=1)^𝑛, where 𝑦_𝑖∈{0,1}, 𝑥_𝑖∈R^(n×F), n is the number of points and F is the feature Number. My idea is to build a graph structure for each 𝑦_𝑖, in which the parameters of the adjacency matrix are randomly initialized and then GCN is performed. How should this be achieved?
Thanks

Most helpful comment

That's an interesting idea. To achieve that, you wan to make edge_weight explicitly learnable and adjust it after each optimizer step. A starting point could be the following:

adj = torch.rand((num_nodes, num_nodes)
edge_index = (adj > 0).nonzero().t()
edge_weight = adj[edge_index[0], edge_index[1]]
edge_weight.requires_grad = True

self.gcn_conv(x, edge_index, edge_weight)
...
loss.backward()

All 4 comments

That's an interesting idea. To achieve that, you wan to make edge_weight explicitly learnable and adjust it after each optimizer step. A starting point could be the following:

adj = torch.rand((num_nodes, num_nodes)
edge_index = (adj > 0).nonzero().t()
edge_weight = adj[edge_index[0], edge_index[1]]
edge_weight.requires_grad = True

self.gcn_conv(x, edge_index, edge_weight)
...
loss.backward()

That's an interesting idea. To achieve that, you wan to make edge_weight explicitly learnable and adjust it after each optimizer step. A starting point could be the following:

adj = torch.rand((num_nodes, num_nodes)
edge_index = (adj > 0).nonzero().t()
edge_weight = adj[edge_index[0], edge_index[1]]
edge_weight.requires_grad = True

self.gcn_conv(x, edge_index, edge_weight)
...
loss.backward()

Thanks for your answer

There are a few papers learning the graph structure along with node features.

For example:
[1] Kazi, A., Cosmo, L., Navab, N. and Bronstein, M., 2020. Differentiable Graph Module (DGM) Graph Convolutional Networks. arXiv preprint arXiv:2002.04999.
https://arxiv.org/pdf/1801.07829.pdf

[2] Wang, Y., Sun, Y., Liu, Z., Sarma, S.E., Bronstein, M.M. and Solomon, J.M., 2019. Dynamic graph cnn for learning on point clouds. Acm Transactions On Graphics (tog), 38(5), pp.1-12.
https://arxiv.org/pdf/2002.04999.pdf
@rusty1s any chance ~~any of these methods
of [1] being implemented in the future?

There are a few papers learning the graph structure along with node features.

For example:
[1] Kazi, A., Cosmo, L., Navab, N. and Bronstein, M., 2020. Differentiable Graph Module (DGM) Graph Convolutional Networks. arXiv preprint arXiv:2002.04999.
https://arxiv.org/pdf/1801.07829.pdf

[2] ~Wang, Y., Sun, Y., Liu, Z., Sarma, S.E., Bronstein, M.M. and Solomon, J.M., 2019. Dynamic graph cnn for learning on point clouds. Acm Transactions On Graphics (tog), 38(5), pp.1-12. https://arxiv.org/pdf/2002.04999.pdf~
[Edit]: the above is already implemented, apologies.

@rusty1s any chance ~any of these methods~ of [1] being implemented in the future?

Thanks for you reply

Was this page helpful?
0 / 5 - 0 ratings