Graph Neural Networks with TensorFlow and Keras. Focused on Molecular Machine Learning.
[!NOTE] For compatability with Keras 3, see the more recent project MolCraft. MolCraft also provides improved featurization of molecules (including the addition of super nodes) and improved modules (including
models.GraphModel,layers.GraphLayerandtensors.GraphTensor).
Quick start
Benchmark the performance of MolGraph here, and implement a complete model pipeline with MolGraph here.
Highlights
Build a Graph Neural Network with Keras' Sequential API:
from molgraph import GraphTensor
from molgraph import layers
from tensorflow import keras
g = 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:
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
- A composite tensor holding graph data; compatible with
tf.data.Dataset,keras.Sequentialand much more.
- A composite tensor holding graph data; compatible with
- Graph tensor
- Layers
- Models
Overview
Documentation
See readthedocs
Papers
Metadata
Release files for molgraph 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| molgraph-0.10.1.tar.gz | 114.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| molgraph-0.10.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 288.0 kB
Release files / molgraph-0.10.1.tar.gz
| Download URL | molgraph-0.10.1.tar.gz |
|---|---|
| Size | 114.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a999f34e0525f1709859cfa69bd32ee01b1633e4b0f6532dcc4ac3f25dcba83
|
|
BLAKE2b-256 checksum How to use checksums |
1850850010063367ff4fc73323349fab60d0ab685f69638a5890a7119ef9cd10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / molgraph-0.10.1-py3-none-any.whl
| Download URL | molgraph-0.10.1-py3-none-any.whl |
|---|---|
| Size | 173.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14f718f6c816358eafa90cba55973ff2de23bcb0149fabf3a713a818b13638fd
|
|
BLAKE2b-256 checksum How to use checksums |
9d48786b0f59465c6f1217e1538d1a225457059cb8c05dcadd8e3709321a6624
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|