Skip to content

Commit 07b2903

Browse files
author
Löffler, Hannes
committed
Merge branch 'main' of github.com:MolecularAI/REINVENT4
2 parents 859c6bc + 3266e54 commit 07b2903

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ instructions on how to configure the TOML file. Internal priors can be referenc
8585
dot notation (see `reinvent/prior_registry.py`).
8686

8787

88+
Prior models
89+
------------
90+
91+
All public prior models can be found on [Zenodo](https://doi.org/10.5281/zenodo.15641296).
92+
93+
8894
Tutorials / `Jupyter` notebooks
8995
-------------------------------
9096

notebooks/Reinvent_demo.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# # _De novo_ Reinforcement Learning with the Reinvent prior
1717
#
1818
# This is a short demo to
19-
# - Set up a reinforcment learning run
20-
# - Carry out a reinforcment learning run
19+
# - Set up a reinforcement learning run
20+
# - Carry out a reinforcement learning run
2121
# - Visualize the results with TensorBoard
2222
# - Extract the raw data from TensorBoard and how to work with it
2323

@@ -37,13 +37,13 @@
3737

3838
# ## Set up the REINVENT run
3939
#
40-
# A work directory is defined and created anew (all previous data deleted if the directory already exsists). The prior file is taken from the REINVENT repository and the agent is initially the same as the prior. A TOML configuration is written out to file in the work directory.
40+
# A work directory is defined and created anew (all previous data deleted if the directory already exists). The prior file is taken from the REINVENT repository and the agent is initially the same as the prior. A TOML configuration is written out to file in the work directory.
4141

4242
wd = "/tmp/R4_notebooks_output"
4343

4444
# ### Delete existing working directory (!)
4545
#
46-
# Skip this step if you have already carried out the RL run but wish to analyis the results further.
46+
# Skip this step if you have already carried out the RL run but wish to analyse the results further.
4747

4848
shutil.rmtree(wd, ignore_errors=True)
4949
os.mkdir(wd)
@@ -66,7 +66,7 @@
6666

6767
# ### Parameters
6868
#
69-
# Here we specify the model files, the prefix for the output CSV summary file and the batch size for sampling and stochastic gradient descent (SGD). The batch size is often given in 2^N but there is in now way required. Typically batch sizes are betwen 50 and 150. Batch size effects on SGD and so also the learning rate. Some experimentation may be required to adjust this but keep in mind that, say, raising the total score as fast as possible is not necessarily the best choice as this may hamper exploration.
69+
# Here we specify the model files, the prefix for the output CSV summary file and the batch size for sampling and stochastic gradient descent (SGD). The batch size is often given in 2^N but there is in now way required. Typically batch sizes are between 50 and 150. Batch size effects on SGD and so also the learning rate. Some experimentation may be required to adjust this but keep in mind that, say, raising the total score as fast as possible is not necessarily the best choice as this may hamper exploration.
7070

7171
# +
7272
prior_filename = os.path.join(reinvent.__path__[0], "..", "priors", "reinvent.prior")
@@ -101,7 +101,7 @@
101101
#
102102
# The stage will terminate when a maximum number of 300 steps is reached. Termination could occur earlier when the maximum score of 1.0 is exceeded but this is very unlikely to occur. A checkpoint file is written out which can be used as the agent in a subsequent stage.
103103
#
104-
# The scoring function is a weighted product of all the scoring components: QED and number of sterecentres. The latter is used here to avoid stereocentres as they are not support by the Reinvent prior. Zero stereocentres aids in downstream 3D task to avoid having to carry out stereocentre enumeration. Custom alerts is a filter which filters out (scores as zero) all generated compounds which match one of the SMARTS patterns. Number of sterecentres uses a transformation function to ensure the component score is between 0 and 1.
104+
# The scoring function is a weighted product of all the scoring components: QED and number of sterecentres. The latter is used here to avoid stereocentres as they are not supported by the Reinvent prior. Zero stereocentres aids in downstream 3D task to avoid having to carry out stereocentre enumeration. Custom alerts is a filter which filters out (scores as zero) all generated compounds which match one of the SMARTS patterns. Number of sterecentres uses a transformation function to ensure the component score is between 0 and 1.
105105

106106
stages = """
107107
[[stage]]
@@ -185,13 +185,13 @@
185185
#
186186
# TensorBoard needs to be started after REINVENT has finished. Scatter plots of all scoring components are shown (raw and transformed) in the _SCALARS_ tab as well as loss and fractions of valid and duplicate (per batch) SMILES. The _IMAGES_ tab shows the first sampled molecules for each recorded RL step labelled with the total score for the molecule.
187187
#
188-
# The loss likehoods (negative log likelihoods, NLL) for the agent is expected to move away from the prior NLL and also have smaller NLLs than the prior. This shows that the agent is increasingly producing molecules different from the prior, closer to the signal from the scoring function as requested. For sample efficiency it is desirable to observed few duplicates and a high number of valid molecules. Note that results are stochastic and will not be different in every run of RL, even with exactly the same configuration.
188+
# The loss likelihoods (negative log likelihoods, NLL) for the agent is expected to move away from the prior NLL and also have smaller NLLs than the prior. This shows that the agent is increasingly producing molecules different from the prior, closer to the signal from the scoring function as requested. For sample efficiency it is desirable to observed few duplicates and a high number of valid molecules. Note that results are stochastic and will not be different in every run of RL, even with exactly the same configuration.
189189

190190
# %tensorboard --bind_all --logdir $wd/tb_stage1_0
191191

192192
# ## Extract data from TensorBoard
193193
#
194-
# TensorBoard data can be directy extracted as shown in this section.
194+
# TensorBoard data can be directly extracted as shown in this section.
195195

196196
# ### Load the TB data
197197

@@ -222,7 +222,7 @@
222222

223223
# ### Sample efficiency
224224
#
225-
# Count the number of total invalid and duplcate SMILES and compare to the total number of generated SMILES.
225+
# Count the number of total invalid and duplicate SMILES and compare to the total number of generated SMILES.
226226

227227
# +
228228
total_smilies = len(df)
@@ -239,7 +239,7 @@
239239
print(
240240
f"Total number of SMILES generated: {total_smilies}\n"
241241
f"Total number of invalid SMILES generated: {total_invalid_smilies}\n"
242-
f"Total number of batcg duplicate SMILES generated: {total_batch_duplicate_smilies}\n"
242+
f"Total number of batch duplicate SMILES generated: {total_batch_duplicate_smilies}\n"
243243
f"Total number of duplicate SMILES generated: {total_duplicate_smilies}"
244244
)
245245
# -

0 commit comments

Comments
 (0)