Giter Club home page Giter Club logo

gated-graph-neural-network-samples's Introduction

Gated Graph Neural Networks

This repository is not maintained anymore. An updated version of the sparse codebase in this repo, together with many more GNN implementations, is available on https://github.com/microsoft/tf-gnn-samples.

This repository contains two implementations of the Gated Graph Neural Networks of Li et al. 2015 for learning properties of chemical molecules. The inspiration for this application comes from Gilmer et al. 2017.

This code was tested in Python 3.5 with TensorFlow 1.3. To run the code docopt is also necessary.

This code was maintained by the Deep Program Understanding project at Microsoft Research, Cambridge, UK.

Data Extraction

To download the related data run get_data.py. It requires the python package rdkit within the Python package environment. For example, this can be obtained by

conda install -c rdkit rdkit

Running Graph Neural Network Training

We provide four versions of Graph Neural Networks: Gated Graph Neural Networks (one implementation using dense adjacency matrices and a sparse variant), Asynchronous Gated Graph Neural Networks, and Graph Convolutional Networks (sparse). The dense version is faster for small or dense graphs, including the molecules dataset (though the difference is small for it). In contrast, the sparse version is faster for large and sparse graphs, especially in cases where representing a dense representation of the adjacency matrix would result in prohibitively large memory usage. Asynchronous GNNs do not propagate information from all nodes to all neighbouring nodes at each timestep; instead, they follow an update schedule such that messages are propagated in sequence. Their implementation is far more inefficient (due to the small number of updates at each step), but a single propagation round (i.e., performing each propagation step along a few edges once) can suffice to propagate messages across a large graph.

To run dense Gated Graph Neural Networks, use

python3 ./chem_tensorflow_dense.py

To run sparse Gated Graph Neural Networks, use

python3 ./chem_tensorflow_sparse.py

To run sparse Graph Convolutional Networks (as in Kipf et al. 2016), use

python3 ./chem_tensorflow_gcn.py

Finally, it turns out that the extension of GCN to different edge types is a variant of GGNN, and you can run GCN (as in Schlichtkrull et al. 2017) by calling

python3 ./chem_tensorflow_sparse.py --config '{"use_edge_bias": false, "use_edge_msg_avg_aggregation": true, "residual_connections": {}, "layer_timesteps": [1,1,1,1,1,1,1,1], "graph_rnn_cell": "RNN", "graph_rnn_activation": "ReLU"}'

To run asynchronous Gated Graph Neural Networks, use

python3 ./chem_tensorflow_async.py

Restoring models

Suppose you have trained a model e.g. the following trains for a single epoch:

python3 ./chem_tensorflow_dense.py --config '{"num_epochs": 1}'
== Epoch 1
 Train: loss: 0.52315 | acc: 0:0.64241 | error_ratio: 0:9.65831 | instances/sec: 6758.04
 Valid: loss: 0.26930 | acc: 0:0.55949 | error_ratio: 0:8.41163 | instances/sec: 9902.71
  (Best epoch so far, cum. val. acc decreased to 0.55949 from inf. Saving to './2018-02-01-11-30-05_16306_model_best.pickle')

Note that a checkpoint was stored to './2018-02-01-11-30-05_16306_model_best.pickle'. To restore this model and continue training, use:

python3 ./chem_tensorflow_dense.py --restore ./2018-02-01-11-30-05_16306_model_best.pickle

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

gated-graph-neural-network-samples's People

Contributors

51alg avatar alexpolozov avatar mallamanis avatar microsoftopensource avatar mmjb avatar msftgits avatar ryotatomioka avatar sahilsuneja1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gated-graph-neural-network-samples's Issues

tying layers

Thanks for sharing the ggnn code. I am a little confused by the concept of layers. It seems that in the earlier version of the codebase, each layer represents one timestep, and there is an option called tie_gnn_layers to toggle the sharing of weights, biases, and rnn cells across all time steps. Later, I noticed that after a commit, layers no longer share those tensors and cells. Does that mean a layer now represent an actual physical layer in the model instead of a time step? Thanks.

PS: since tying layers is no longer an option, the README file still includes an obsolete parameter "tie_gnn_layers": false for GCN. The comment about tying layers also seems to be obsolete.

reported loss

Hi!
It seems to me that the training/ test 'loss' reported per epoch is the mean absolute error average_per_moelcule(|y-y*|). Is that correct? I am new to tf so the syntax is not very intuitive to me.

Thanks!

Please explain comments like ' # [b x v x h]'

Hello,
I'm reading your code and I'd like to use gnn in my work. I noticed that you added some comments like ' # [b x v x h]' in your code. I guess understanding these comments will help me understand these quickly. While I'm not sure about what these characters actually mean. Especially I can't figure out what 'b' means. Could you please explain what 'b','v','e','h' mean in chem_tensorflow_dense.py? It will help me a lot.

Thank you very much!
Jennifer

Chemical accuracy values

Hello,
I am trying to reproduce results from the Gilmer et al., 2017 paper and have noticed that they mention normalizing of the targets. However, the chemical accuracies used do not seem to be normalized in their Supplementary Table. In your code, those values are different from Faber et al., 2017 and Gilmer et al., 2017. Would you mind explaining how you derived them?
Also, does your validation split reproduce the one mentioned in Gilmer et al., 2017, or was it random?
Thank you!
Best,

Can I use float rather than int in the graph?

Hello:
I want to use this awesome tool on my chemical reaction path search, but I want to make graphs from molecule coordinates, so the graph in .json file should be [<atom_idx1>, distance of atom1,2 , <atom_idx2>], rather than single_bond = 1, double_bond = 2, trans_bond = 3, the targets is molecule energy, it changes with atom distance.

I don't know much about your algorithm, so I tried to change these int into different float, only chem_tensorflow_async.py works(chem_tensorflow_gcn.py works but results keep same), but I don't know if it really did what I want.
So I want to know can I use float in the graph, is algorithm supported for this function?
qq 20180803104453

Dense for small graph?

Hi,

I was wondering typically what on what order of the size of graph shall be classified as "small", so that the dense version will be more beneficial than sparse version? I know I can benchmark this myself, but some expert comments will give me a good prior! Thanks!

Explaining data in .json files

The following are data that follow this model downloaded by me:
Here is a json object from valid.json
{ "targets": [ [ -0.3917742606773421 ] ], "graph": [ [ 0, 2, 1 ], [ 0, 1, 2 ], [ 0, 1, 3 ] ], "node_features": [ [ 0, 1, 0, 0, 0 ], [ 0, 0, 0, 1, 0 ], [ 1, 0, 0, 0, 0 ], [ 1, 0, 0, 0, 0 ] ] }

I wonder how the graph data (edges) are presented.

In the example above:

  • graph data are (0,2,1), (0,1,2), (0,1,3)

Do you use GPU for training?

Thank you for your great work.

When you train your model, do you set your tensorflow with GPU or not? How long will it take for your training?

I pip install -r requirements.txt, then run. It showed that I am using CPU. Even though I install tensowflow-gpu, it still running on CPU. Any advice? Thanks a lot.

Unable to wget the sample data

Thank you for sharing the ggnn codes. When I was trying to run the testing samples, I found I cannot get the sample data from the target URL neither by using get_data.py nor wget (with "unable to establish SSL connection") nor curl ("SSL_ERROR_SYSCALL"). May I please know if you shared testing data sample is still reachable? Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.