{"id":27438376,"url":"https://github.com/coderpat/opengnn","last_synced_at":"2026-03-07T07:32:41.540Z","repository":{"id":49405418,"uuid":"167866182","full_name":"CoderPat/OpenGNN","owner":"CoderPat","description":"Open source machine learning for graph-structured data","archived":false,"fork":false,"pushed_at":"2019-05-09T05:06:18.000Z","size":100,"stargazers_count":30,"open_issues_count":4,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T20:44:33.942Z","etag":null,"topics":["deep-learning","graph-neural-networks"],"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/CoderPat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-27T22:29:54.000Z","updated_at":"2024-11-06T14:05:08.000Z","dependencies_parsed_at":"2022-08-28T00:11:37.027Z","dependency_job_id":null,"html_url":"https://github.com/CoderPat/OpenGNN","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CoderPat/OpenGNN","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderPat%2FOpenGNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderPat%2FOpenGNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderPat%2FOpenGNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderPat%2FOpenGNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoderPat","download_url":"https://codeload.github.com/CoderPat/OpenGNN/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoderPat%2FOpenGNN/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30209731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deep-learning","graph-neural-networks"],"created_at":"2025-04-14T20:35:21.732Z","updated_at":"2026-03-07T07:32:41.525Z","avatar_url":"https://github.com/CoderPat.png","language":"Python","readme":"# OpenGNN\n\nOpenGNN is a machine learning library for learning over graph-structured data. It was built with generality in mind and supports tasks such as:\n\n* graph regression\n* graph-to-sequence mapping\n\nIt supports various graph encoders including GGNNs, GCNs, SequenceGNNs and other variations of [neural graph message passing](https://arxiv.org/pdf/1704.01212.pdf).\n\nThis library's design and usage patterns are inspired from [OpenNMT](https://github.com/OpenNMT/OpenNMT-tf) and uses the recent [Dataset](https://www.tensorflow.org/programmers_guide/datasets) and [Estimator](https://www.tensorflow.org/programmers_guide/estimators) APIs.\n\n## Installation\n\nOpenGNN requires \n\n* Python (\u003e= 3.5)\n* Tensorflow (\u003e= 1.10 \u003c 2.0)\n\nTo install the library aswell as the command-line entry points run\n\n``` pip install -e .```\n\n## Getting Started\n\nTo experiment with the library, you can use one datasets provided in the [data](/data) folder.\nFor example, to experiment with the chemical dataset, first install the `rdkit` library that \ncan be obtained by running `conda install -c rdkit rdkit`.\nThen, in the [data/chem](/data/chem) folder, run `python get_data.py` to download the dataset.\n\nAfter getting the data, generate a node and edge vocabulary for them using \n```bash\nognn-build-vocab --field_name node_labels --save_vocab node.vocab \\\n                 molecules_graphs_train.jsonl\nognn-build-vocab --no_pad_token --field_name edges --string_index 0 --save_vocab edge.vocab \\\n                 molecules_graphs_train.jsonl\n```\n\n### Command Line\n\nThe main entry point to the library is the `ognn-main` command\n\n```bash\nognn-main \u003crun_type\u003e --model_type \u003cmodel\u003e --config \u003cconfig_file.yml\u003e\n```\n\nCurrently there are two run types: `train_and_eval` and `infer`\n\nFor example, to train a model on the previously extracted chemical data\n(again inside [data/chem](/data/chem)) using a predefined model in the \ncatalog\n\n```bash\nognn-main train_and_eval --model_type chemModel --config config.yml\n```\n\nYou can also define your own model in a custom python script with a `model` function.\nFor example, we can train using the a custom model in `model.py` using\n\n```bash\nognn-main train_and_eval --model model.py --config config.yml\n```\n\nWhile the training script doesn't log the training to the standard output, \nwe can monitor training by using tensorboard on the model directory defined in\n[data/chem/config.yml](data/chem/config.yml).\n\nAfter training, we can perform inference on the valid file running\n\n```\nognn-main infer --model_type chemModel --config config.yml \\\n                --features_file molecules_graphs_valid.jsonl\n                --prediction_file molecules_predicted_valid.jsonl\n```\n\n\nExamples of other config files can be found in the [data](/data) folder.\n\n### Library\n\nThe library can also be easily integrated in your own code.\nThe following example shows how to create a GGNN Encoder to encode a batch of random graphs.\n\n```python\nimport tensorflow as tf\nimport opengnn as ognn\n\ntf.enable_eager_execution()\n\n# build a batch of graphs with random initial features\nedges = tf.SparseTensor(\n    indices=[\n        [0, 0, 0, 1], [0, 0, 1, 2],\n        [1, 0, 0, 0],\n        [2, 0, 1, 0], [2, 0, 2, 1], [2, 0, 3, 2], [2, 0, 4, 3]],\n    values=[1, 1, 1, 1, 1, 1, 1],\n    dense_shape=[3, 1, 5, 5])\nnode_features = tf.random_uniform((3, 5, 256))\ngraph_sizes = [3, 1, 5]\n\nencoder = ognn.encoders.GGNNEncoder(1, 256)\noutputs, state = encoder(\n    edges,\n    node_features,\n    graph_sizes)\n\nprint(outputs)\n```\n\nGraphs are represented by a sparse adjency matrix with dimensionality \n`num_edge_types x num_nodes x num_nodes` and an initial distributed representation for each node.\n\nSimilarly to sequences, when batching we need to pad the graphs to the maximum number of nodes in a graph\n\n\n## Acknowledgments\nThe design of the library and implementations are based on \n* [OpenNMT-tf](https://github.com/OpenNMT/OpenNMT-tf)\n* [Gated Graph Neural Networks](https://github.com/Microsoft/gated-graph-neural-network-samples)\n\nSince most of the code adapted from OpenNMT-tf is spread across multiple files, the license for the\nlibrary is located in the [base folder](/OPENNMT.LICENSE) rather than in the headers of the files.\n\n## Reference\n\nIf you use this library in your own research, please cite\n\n```\n@inproceedings{\n    pfernandes2018structsumm,\n    title=\"Structured Neural Summarization\",\n    author={Patrick Fernandes and Miltiadis Allamanis and Marc Brockschmidt },\n    booktitle={Proceedings of the 7th International Conference on Learning Representations (ICLR)},\n    year={2019},\n    url={https://arxiv.org/abs/1811.01824},\n}\n```\n\n\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderpat%2Fopengnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderpat%2Fopengnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderpat%2Fopengnn/lists"}