{"id":13958803,"url":"https://github.com/microsoft/gated-graph-neural-network-samples","last_synced_at":"2025-09-27T10:30:53.938Z","repository":{"id":65975489,"uuid":"110565580","full_name":"microsoft/gated-graph-neural-network-samples","owner":"microsoft","description":"Sample Code for Gated Graph Neural Networks","archived":true,"fork":false,"pushed_at":"2019-10-10T09:27:16.000Z","size":150,"stargazers_count":1027,"open_issues_count":2,"forks_count":259,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-09-24T00:36:50.091Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-13T15:28:43.000Z","updated_at":"2025-09-07T03:45:34.000Z","dependencies_parsed_at":"2023-02-19T19:00:27.653Z","dependency_job_id":null,"html_url":"https://github.com/microsoft/gated-graph-neural-network-samples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/microsoft/gated-graph-neural-network-samples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fgated-graph-neural-network-samples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fgated-graph-neural-network-samples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fgated-graph-neural-network-samples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fgated-graph-neural-network-samples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/gated-graph-neural-network-samples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fgated-graph-neural-network-samples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277218772,"owners_count":25781445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-08T13:01:52.523Z","updated_at":"2025-09-27T10:30:53.586Z","avatar_url":"https://github.com/microsoft.png","language":"Python","funding_links":[],"categories":["其他_图神经网络GNN"],"sub_categories":["网络服务_其他"],"readme":"# Gated Graph Neural Networks\n\n\u003e ## 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.\n\nThis repository contains two implementations of the Gated Graph Neural Networks\nof [Li et al. 2015](https://arxiv.org/abs/1511.05493) for learning properties of chemical molecules.\nThe inspiration for this application comes from [Gilmer et al. 2017](https://arxiv.org/abs/1704.01212).\n\nThis code was tested in Python 3.5 with TensorFlow 1.3. To run the code `docopt` is also necessary.\n\nThis code was maintained by the [Deep Program Understanding](https://www.microsoft.com/en-us/research/project/program/) project at Microsoft Research, Cambridge, UK.\n\n## Data Extraction\nTo download the related data run `get_data.py`. It requires the python package `rdkit` within the Python package\nenvironment. For example, this can be obtained by\n```\nconda install -c rdkit rdkit\n```\n\n## Running Graph Neural Network Training\nWe provide four versions of Graph Neural Networks: Gated Graph Neural Networks (one implementation using dense\nadjacency matrices and a sparse variant), Asynchronous Gated Graph Neural Networks, and Graph Convolutional\nNetworks (sparse).\nThe dense version is faster for small or dense graphs, including the molecules dataset (though the difference is\nsmall for it). In contrast, the sparse version is faster for large and sparse graphs, especially in cases where\nrepresenting a dense representation of the adjacency matrix would result in prohibitively large memory usage.\nAsynchronous GNNs do not propagate information from all nodes to all neighbouring nodes at each timestep;\ninstead, they follow an update schedule such that messages are propagated in sequence. Their implementation\nis far more inefficient (due to the small number of updates at each step), but a single propagation round\n(i.e., performing each propagation step along a few edges once) can suffice to propagate messages across a\nlarge graph.\n\nTo run dense Gated Graph Neural Networks, use\n```\npython3 ./chem_tensorflow_dense.py\n```\n\nTo run sparse Gated Graph Neural Networks, use\n```\npython3 ./chem_tensorflow_sparse.py\n```\n\nTo run sparse Graph Convolutional Networks (as in [Kipf et al. 2016](https://arxiv.org/abs/1609.02907)), use\n```\npython3 ./chem_tensorflow_gcn.py\n```\n\nFinally, it turns out that the extension of GCN to different edge types is a variant of GGNN, and you can run\nGCN (as in [Schlichtkrull et al. 2017](https://arxiv.org/abs/1703.06103)) by calling\n```\npython3 ./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\"}'\n```\n\nTo run asynchronous Gated Graph Neural Networks, use\n```\npython3 ./chem_tensorflow_async.py\n```\n\n## Restoring models\n\nSuppose you have trained a model e.g. the following trains for a single epoch:\n\n```\npython3 ./chem_tensorflow_dense.py --config '{\"num_epochs\": 1}'\n== Epoch 1\n Train: loss: 0.52315 | acc: 0:0.64241 | error_ratio: 0:9.65831 | instances/sec: 6758.04\n Valid: loss: 0.26930 | acc: 0:0.55949 | error_ratio: 0:8.41163 | instances/sec: 9902.71\n  (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')\n```\n\nNote that a checkpoint was stored to './2018-02-01-11-30-05_16306_model_best.pickle'. To restore this model and continue training, use:\n```\npython3 ./chem_tensorflow_dense.py --restore ./2018-02-01-11-30-05_16306_model_best.pickle\n```\n\n\n\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fgated-graph-neural-network-samples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fgated-graph-neural-network-samples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fgated-graph-neural-network-samples/lists"}