https://github.com/akensert/molgraph
Graph neural networks for molecular machine learning. Implemented and compatible with TensorFlow and Keras.
https://github.com/akensert/molgraph
bioinformatics cheminformatics computational-biology computational-chemistry deep-learning graph-neural-networks graphs keras machine-learning tensorflow
Last synced: 4 days ago
JSON representation
Graph neural networks for molecular machine learning. Implemented and compatible with TensorFlow and Keras.
- Host: GitHub
- URL: https://github.com/akensert/molgraph
- Owner: akensert
- License: mit
- Created: 2022-08-12T14:10:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-04T10:40:15.000Z (about 1 month ago)
- Last Synced: 2025-06-04T17:15:19.477Z (about 1 month ago)
- Topics: bioinformatics, cheminformatics, computational-biology, computational-chemistry, deep-learning, graph-neural-networks, graphs, keras, machine-learning, tensorflow
- Language: Python
- Homepage: https://molgraph.readthedocs.io/en/latest/
- Size: 1.73 MB
- Stars: 54
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
**Graph Neural Networks** with **TensorFlow** and **Keras**. Focused on **Molecular Machine Learning**.
## Quick start
Benchmark the performance of MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/GNN-Benchmarking.ipynb), and implement a complete model pipeline with MolGraph [here](https://github.com/akensert/molgraph/blob/main/examples/QSAR-GNN-Tutorial.ipynb).## Highlights
Build a Graph Neural Network with Keras' [Sequential](https://www.tensorflow.org/api_docs/python/tf/keras/Sequential) API:```python
from molgraph import GraphTensor
from molgraph import layers
from tensorflow import kerasg = GraphTensor(node_feature=[[4.], [2.]], edge_src=[0], edge_dst=[1])
model = keras.Sequential([
layers.GNNInput(type_spec=g.spec),
layers.GATv2Conv(units=32),
layers.GATv2Conv(units=32),
layers.Readout(),
keras.layers.Dense(units=1),
])pred = model(g)
# Save and load Keras model
model.save('/tmp/gatv2_model.keras')
loaded_model = keras.models.load_model('/tmp/gatv2_model.keras')
loaded_pred = loaded_model(g)
assert pred == loaded_pred
```Combine outputs of GNN layers to improve predictive performance:
```python
model = keras.Sequential([
layers.GNNInput(type_spec=g.spec),
layers.GNN([
layers.FeatureProjection(units=32),
layers.GINConv(units=32),
layers.GINConv(units=32),
layers.GINConv(units=32),
]),
layers.Readout(),
keras.layers.Dense(units=128),
keras.layers.Dense(units=1),
])model.summary()
```## Installation
For **CPU** users:
pip install molgraph
For **GPU** users:
pip install molgraph[gpu]## Implementations
- **Tensors**
- [Graph tensor](http://github.com/akensert/molgraph/tree/main/molgraph/tensors/graph_tensor.py)
- A composite tensor holding graph data; compatible with `tf.data.Dataset`, `keras.Sequential` and much more.
- **Layers**
- [Graph convolutional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/convolutional/)
- [Graph attentional layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/attentional/)
- [Graph message passing layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/message_passing/)
- [Graph readout layers](http://github.com/akensert/molgraph/tree/main/molgraph/layers/readout/)
- [Preprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/preprocessing/)
- [Postprocessing layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/postprocessing/)
- [Positional encoding layers](https://github.com/akensert/molgraph/tree/main/molgraph/layers/positional_encoding)
- **Models**
- [Graph neural networks](https://github.com/akensert/molgraph/tree/main/molgraph/models/)
- [Saliency mapping](https://github.com/akensert/molgraph/tree/main/molgraph/models/interpretability/)## Overview
## Documentation
See [readthedocs](https://molgraph.readthedocs.io/en/latest/)## Papers
- [MolGraph: a Python package for the implementation of molecular graphs and graph neural networks with TensorFlow and Keras](https://doi.org/10.48550/arXiv.2208.09944)
- [A hands-on tutorial on quantitative structure-activity relationships using fully expressive graph neural networks](https://doi.org/10.1016/j.aca.2024.343046)