pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
20.69k stars 3.59k forks source link

GraphVAE for molecular generation #1292

Open xiaolinpan opened 4 years ago

xiaolinpan commented 4 years ago

I am a novice for graph generation. I notice the vae in PyG only can generate Adjacency matrix. Could you help me implememt the graphvae for molelualr generation? How to generate the atom type and bond type? thank you very much! https://arxiv.org/pdf/1802.03480.pdf

rusty1s commented 4 years ago

The GraphVAE is somewhat difficult to implement since you can only utilize PyG for the Encoder part. The Decoder can be modeled by three different MLPs that map to [batch_size, num_nodes, num_nodes], [batch_size, num_nodes, num_nodes, num_bond_types], and [batch_size, num_nodes, num_atom_types] outputs. In addition, you need to implement the graph matching algorithm from Section 3.4 to train the model.

xiaolinpan commented 4 years ago

thanks for your suggestions!

Yaoyx commented 3 years ago

Hi guys,

I am trying to figure out how to construct a molecule graph with bond information, but I am confused about how the decoder is modeled by three different MLPs. Would you guys mind explaining it a bit more?

Many many thanks

rusty1s commented 3 years ago

As far as I know, the decoders of GraphVAE are just plain MLPs that map a low-dimensional vector z to (num_nodes, num_node_features), (num_nodes, num_nodes), and (num_nodes, num_nodes, num_edge_features), respectively.

Yaoyx commented 3 years ago

Thank you so much. I will try it out.

leosv123 commented 3 years ago

As far as I know, the decoders of GraphVAE are just plain MLPs that map a low-dimensional vector z to (num_nodes, num_node_features), (num_nodes, num_nodes), and (num_nodes, num_nodes, num_edge_features), respectively.

I am trying to use PyG to generate new molecules, this is the paper i am trying to implement (https://arxiv.org/pdf/1908.08612.pdf) paper, can you help me how to get the nodes to build the graph.

rusty1s commented 3 years ago

Is there some open-source version of it available somewhere? Other-wise, it might be good to tell me which step you are currently implementing and what you have tried so far.

shrimonmuke0202 commented 1 year ago

How can I map Z of shape (# nodes, 256) into (# nodes, # nodes, # edge features)?

rusty1s commented 1 year ago

You can do:

z_src = z.view(1, num_nodes, num_features).repeat(num_nodes, 1, 1)
z_dst = z.view(num_nodes, 1, num_features).repeat(1, num_nodes, 1)

MLP(torch.cat([z_src, z_dst], dim=-1))
shrimonmuke0202 commented 1 year ago

Thanks for your reply, I came to know that molecular graph generation has three state-of-the-art models GraphVAE, GraphRNN, and Junction Tree Variational Autoencoders for Molecular graph generation. Which model should I use for molecular graph generation?

rusty1s commented 1 year ago

I am not an expert on graph generation, but I think that in the molecular graph setting, the junction tree representation is the most promising.