Skip to content

Commit

Permalink
add space and model hub for molecule generation with VAE example (ker…
Browse files Browse the repository at this point in the history
  • Loading branch information
vumichien authored Jul 7, 2022
1 parent 1382cca commit a01a0e3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
31 changes: 16 additions & 15 deletions examples/generative/ipynb/molecule_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@
"source": [
"## Dataset\n",
"\n",
"We use the [**ZINC \u2013 A Free Database of Commercially Available Compounds for\n",
"We use the [**ZINC A Free Database of Commercially Available Compounds for\n",
"Virtual Screening**](https://bit.ly/3IVBI4x) dataset. The dataset comes with molecule\n",
"formula in SMILE representation along with their respective molecular properties such as\n",
"**logP** (water\u2013octanal partition coefficient), **SAS** (synthetic\n",
"**logP** (water–octanal partition coefficient), **SAS** (synthetic\n",
"accessibility score) and **QED** (Qualitative Estimate of Drug-likeness)."
]
},
Expand Down Expand Up @@ -260,8 +260,7 @@
" if flag != Chem.SanitizeFlags.SANITIZE_NONE:\n",
" return None\n",
"\n",
" return molecule\n",
""
" return molecule\n"
]
},
{
Expand Down Expand Up @@ -355,8 +354,7 @@
" # Reduce bond types dim\n",
" x_reduced = tf.reduce_sum(x, axis=1)\n",
" # Apply non-linear transformation\n",
" return self.activation(x_reduced)\n",
""
" return self.activation(x_reduced)\n"
]
},
{
Expand All @@ -376,9 +374,9 @@
"non-linearly transformed neighbourhood aggregations. We can define these layers as\n",
"follows:\n",
"\n",
"`H_hat**(l+1) = \u03c3(D_hat**(-1) * A_hat * H_hat**(l+1) * W**(l))`\n",
"`H_hat**(l+1) = σ(D_hat**(-1) * A_hat * H_hat**(l+1) * W**(l))`\n",
"\n",
"Where `\u03c3` denotes the non-linear transformation (commonly a ReLU activation), `A` the\n",
"Where `σ` denotes the non-linear transformation (commonly a ReLU activation), `A` the\n",
"adjacency tensor, `H_hat**(l)` the feature tensor at the `l-th` layer, `D_hat**(-1)` the\n",
"inverse diagonal degree tensor of `A_hat`, and `W_hat**(l)` the trainable weight tensor\n",
"at the `l-th` layer. Specifically, for each bond type (relation), the degree tensor\n",
Expand Down Expand Up @@ -452,8 +450,7 @@
" latent_inputs, outputs=[x_adjacency, x_features], name=\"decoder\"\n",
" )\n",
"\n",
" return decoder\n",
""
" return decoder\n"
]
},
{
Expand All @@ -480,8 +477,7 @@
" batch = tf.shape(z_log_var)[0]\n",
" dim = tf.shape(z_log_var)[1]\n",
" epsilon = tf.keras.backend.random_normal(shape=(batch, dim))\n",
" return z_mean + tf.exp(0.5 * z_log_var) * epsilon\n",
""
" return z_mean + tf.exp(0.5 * z_log_var) * epsilon\n"
]
},
{
Expand Down Expand Up @@ -639,8 +635,7 @@
"\n",
" property_pred = self.property_prediction_layer(z_mean)\n",
"\n",
" return z_mean, log_var, property_pred, gen_adjacency, gen_features\n",
""
" return z_mean, log_var, property_pred, gen_adjacency, gen_features\n"
]
},
{
Expand Down Expand Up @@ -766,7 +761,13 @@
"while the later paper considers SMILES inputs as graphs (a combination of adjacency\n",
"matrices and feature matrices) and seeks to generate molecules as graphs.\n",
"\n",
"This hybrid approach enables a new type of directed gradient-based search through chemical space."
"This hybrid approach enables a new type of directed gradient-based search through chemical space.\n",
"\n",
"Example available on HuggingFace\n",
"\n",
"| Trained Model | Demo |\n",
"| :--: | :--: |\n",
"| [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Model-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/keras-io/drug-molecule-generation-with-VAE) | [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Spaces-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/spaces/keras-io/generating-drug-molecule-with-VAE) |"
]
}
],
Expand Down
6 changes: 6 additions & 0 deletions examples/generative/md/molecule_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,3 +737,9 @@ while the later paper considers SMILES inputs as graphs (a combination of adjace
matrices and feature matrices) and seeks to generate molecules as graphs.

This hybrid approach enables a new type of directed gradient-based search through chemical space.

Example available on HuggingFace

| Trained Model | Demo |
| :--: | :--: |
| [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Model-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/keras-io/drug-molecule-generation-with-VAE) | [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Spaces-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/spaces/keras-io/generating-drug-molecule-with-VAE) |
6 changes: 6 additions & 0 deletions examples/generative/molecule_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,10 @@ def plot_latent(vae, data, labels):
matrices and feature matrices) and seeks to generate molecules as graphs.
This hybrid approach enables a new type of directed gradient-based search through chemical space.
Example available on HuggingFace
| Trained Model | Demo |
| :--: | :--: |
| [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Model-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/keras-io/drug-molecule-generation-with-VAE) | [![Generic badge](https://img.shields.io/badge/%F0%9F%A4%97%20Spaces-molecule%20generation%20with%20VAE-black.svg)](https://huggingface.co/spaces/keras-io/generating-drug-molecule-with-VAE) |
"""

0 comments on commit a01a0e3

Please sign in to comment.