Code Monkey home page Code Monkey logo

retrotemp's Introduction

retrotemp

Neural network for predicting template relevance a la Segler and Waller's Neural Symbolic paper.

Dependencies if you want to use the final model

  • RDKit (most versions should be fine)
  • numpy

Dpendencies if you want to retrain on your own data

  • RDKit (most versions should be fine)
  • tensorflow (r0.12.0)
  • h5py
  • numpy

About

Learn to predict template relevance.

  1. Grab reaction precedents from templates stored in MongoDB python scripts/get_reaxys_data.py

  2. Calculate fingerprints and store in .h5 file python scripts/make_data_file.py data/reaxys_limit1000000000_reaxys_v2_transforms_retro_v9_10_5.txt 2048

  3. Train model python retrotemp/nntrain_fingerprint.py -t data/reaxys_limit1000000000_reaxys_v2_transforms_retro_v9_10_5.txt -o 163723 -m models/6d3M_Reaxys_10_5 --fp_len 2048

  4. Find best validation performance

    regex="model\.(.*)\.meta"
    for f in `ls -tr models/6d3M_Reaxys_10_5/*.meta`
    do
        if [[ $f =~ $regex ]]
        then
            ckpt="${BASH_REMATCH[1]}"
            echo $ckpt
            python retrotemp/nntrain_fingerprint.py  -o 163723 -m models/6d3M_Reaxys_10_5 --fp_len 2048 -c "$ckpt" -t data/reaxys_limit1000000000_reaxys_v2_transforms_retro_v9_10_5.txt --test valid
        fi
    done
    
  5. Retrain on whole dataset (?) for same number of epochs. Note: this is because we want a high-performing deployed model and no longer need to hold out any data. python retrotemp/nntrain_fingerprint.py -t data/reaxys_limit1000000000_reaxys_v2_transforms_retro_v9_10_5.txt -o 163723 -m models/6d3M_Reaxys_10_5 --fp_len 2048 --fixed_epochs_train_all 15

  6. Run standalone tensorflow version to dump to numpy arrays

retrotemp's People

Contributors

connorcoley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

retrotemp's Issues

No module named 'rdkit'

python scripts/get_reaxys_data.py
Traceback (most recent call last):
File "scripts/get_reaxys_data.py", line 3, in
import rdkit.Chem as Chem
ModuleNotFoundError: No module named 'rdkit'

'Tensor' object has no attribute 'sparse_read'

While training the model, by running 'nntrain_fingerprint' script (following the instructions in README), I get the following error -

Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2734, in gather
return params.sparse_read(indices, name=name)
AttributeError: 'Tensor' object has no attribute 'sparse_read'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1104, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 235, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 441, in make_tensor_proto
_GetDenseDimensions(values)))
ValueError: Argument must be a dense tensor: range(0, 1) - got shape [1], but wanted [].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 524, in _apply_op_helper
values, as_ref=input_arg.is_ref).dtype.name
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1104, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 235, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 441, in make_tensor_proto
_GetDenseDimensions(values)))
ValueError: Argument must be a dense tensor: range(0, 1) - got shape [1], but wanted [].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "retrotemp/nntrain_fingerprint.py", line 90, in
mol_hiddens = tf.nn.relu(linearND(input_mol, hidden_size, scope="encoder0"))
File "/home/jupyter/notebooks/utils/nn.py", line 22, in linearND
X_shape = tf.gather(tf.shape(input_), range(ndim-1))
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2736, in gather
return gen_array_ops.gather_v2(params, indices, axis, name=name)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 3065, in gather_v2
"GatherV2", params=params, indices=indices, axis=axis, name=name)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 528, in _apply_op_helper
(input_name, err))
ValueError: Tried to convert 'indices' to a tensor and failed. Error: Argument must be a dense tensor: range(0, 1) - got shape [1], but wanted []

This seems more like a tf problem than retrotemp. Could you please help me with this?

No module named 'makeit'

File "scripts/get_reaxys_data.py", line 37, in
import makeit.retrosynthetic.transformer as transformer
ModuleNotFoundError: No module named 'makeit'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.