Implementations of graph neural networks for molecular machine learning
Project description
MolGraph: Graph Neural Networks for Molecular Machine Learning
This is an early release; things are still being updated and added. Hence, API compatibility may break in the future.
Any feedback is welcomed!
Manuscript
See pre-print
Documentation
See readthedocs
Installation
Install via pip:
pip install molgraph
Install via docker:
git clone https://github.com/akensert/molgraph.git cd molgraph/docker docker build -t molgraph-tf[-gpu][-jupyter]/molgraph:0.0 molgraph-tf[-gpu][-jupyter]/ docker run -it [-p 8888:8888] molgraph-tf[-gpu][-jupyter]/molgraph:0.0
Now run your first program with MolGraph:
from tensorflow import keras
from molgraph import chemistry
from molgraph import layers
from molgraph import models
# Obtain dataset, specifically ESOL
qm7 = chemistry.datasets.get('esol')
# Define molecular graph encoder
atom_encoder = chemistry.AtomicFeaturizer([
chemistry.features.Symbol(),
chemistry.features.Hybridization(),
# ...
])
bond_encoder = chemistry.AtomicFeaturizer([
chemistry.features.BondType(),
# ...
])
encoder = chemistry.MolecularGraphEncoder(atom_encoder, bond_encoder)
# Obtain features and associated labels
x_train = encoder(qm7['train']['x'])
y_train = qm7['train']['y']
x_test = encoder(qm7['test']['x'])
y_test = qm7['test']['y']
# Build model via Keras API
gnn_model = keras.Sequential([
keras.layers.Input(type_spec=x_train.spec),
layers.GATConv(name='gat_conv_1'),
layers.GATConv(name='gat_conv_2'),
layers.Readout(),
keras.layers.Dense(units=1024, activation='relu'),
keras.layers.Dense(units=y_train.shape[-1])
])
# Compile, fit and evaluate
gnn_model.compile(optimizer='adam', loss='mae')
gnn_model.fit(x_train, y_train, epochs=50)
gnn_model.evaluate(x_test, y_test)
# Compute gradient activation maps
gam_model = models.GradientActivationMapping(
model=gnn_model, layer_names=['gat_conv_1', 'gat_conv_2'])
maps = gam_model.predict(x_train)
Requirements/dependencies
- Python (version ~= 3.8.10)
- TensorFlow (version ~= 2.7.0)
- RDKit (version ~= 2022.3.3)
- NumPy (version ~= 1.21.2)
- Pandas (version ~= 1.0.3)
Tested with
- Ubuntu 20.04 - Python 3.8.10
- MacOS Monterey (12.3.1) - Python 3.10.3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
molgraph-0.1.1.tar.gz
(84.2 kB
view details)
Built Distribution
molgraph-0.1.1-py3-none-any.whl
(137.5 kB
view details)
File details
Details for the file molgraph-0.1.1.tar.gz
.
File metadata
- Download URL: molgraph-0.1.1.tar.gz
- Upload date:
- Size: 84.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e120756d3b034f1547c256d99dca3f0fd1e89d9341b10fb0b54a5b6df1a7a70 |
|
MD5 | c651bc0e748f3eefd955d0d77d383f41 |
|
BLAKE2b-256 | 98bc44eb563cdcde9dfe094d9a6f7fd9f3d1464ea34054a320830353e351b1e0 |
File details
Details for the file molgraph-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: molgraph-0.1.1-py3-none-any.whl
- Upload date:
- Size: 137.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7297691b8d946c0fb1d804c86352136ef6611b06440386692d35dc4080df587 |
|
MD5 | 62ba68eceae0f9b70d37df94aa92bf50 |
|
BLAKE2b-256 | e2017d3ace254684b5140547c09fad435d291cde88ff379060a06d88a990f1e5 |