Skip to content

Commit

Permalink
cpu thread flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Winter committed Jul 16, 2019
1 parent b0b1ac6 commit 2a15731
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ The r2 on the Lipophilicity dataset should be arround 0.731 +/- 0.029.
## Getting Started
### Extracting Molecular Descripotrs
Run the script run_cddd.py to extract molecular descripotrs of your provided SMILES:
<<<<<<< HEAD
```bash
cddd --input smiles.smi --output descriptors.csv --smiles_header smiles
```
Expand Down
4 changes: 3 additions & 1 deletion cddd/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def embedding2sequence(model, hparams, embedding, num_top=1, maximum_iterations=
class InferenceModel(object):
"""Class that handles the inference of a trained model."""
def __init__(self, model_dir=_default_model_dir, use_gpu=True, batch_size=256,
gpu_mem_frac=0.1, beam_width=10, num_top=1, maximum_iterations=1000, emb_activation=None):
gpu_mem_frac=0.1, beam_width=10, num_top=1, maximum_iterations=1000,
cpu_threads=5, emb_activation=None):
"""Constructor for the inference model.
Args:
Expand All @@ -103,6 +104,7 @@ def __init__(self, model_dir=_default_model_dir, use_gpu=True, batch_size=256,
self.hparams.set_hparam("batch_size", batch_size)
self.hparams.set_hparam("gpu_mem_frac", gpu_mem_frac)
self.hparams.add_hparam("beam_width", beam_width)
self.hparams.set_hparam("cpu_threads", cpu_threads)
self.encode_model, self.decode_model = build_models(self.hparams,
modes=["ENCODE", "DECODE"])
self.maximum_iterations = maximum_iterations
Expand Down
2 changes: 1 addition & 1 deletion cddd/model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def build_models(hparams, modes=["TRAIN", "EVAL", "ENCODE"]):
def create_model(mode, model_creator, input_pipeline_creator, hparams):
"""Helper function to build a translation model for a certain mode.
Args:
Args:cpu_threads
mode: The mode the model is supposed to run(e.g. Train, EVAL, ENCODE, DECODE).
model_creator: Type of model class (e.g. NoisyGRUSeq2SeqWithFeatures).
input_pipeline_creator: Type of input pipeline class (e.g. InputPipelineWithFeatures).
Expand Down
3 changes: 2 additions & 1 deletion example/run_qsar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def add_arguments(parser):
parser.add_argument('--use_gpu', dest='gpu', action='store_true')
parser.set_defaults(gpu=False)
parser.add_argument('--device', default="0", type=str)
parser.add_argument('--cpu_threads', default=5, type=int)

def main(unused_argv):
"""Main function to test the performance of the translation model to extract
Expand All @@ -44,7 +45,7 @@ def main(unused_argv):
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
model_dir = FLAGS.model_dir

infer_model = InferenceModel(model_dir, use_gpu=FLAGS.gpu)
infer_model = InferenceModel(model_dir, use_gpu=FLAGS.gpu, cpu_threads=FLAGS.cpu_threads)
ames_df = pd.read_csv("ames.csv")
ames_smls = ames_df.smiles.tolist()
ames_labels = ames_df.label.values
Expand Down

0 comments on commit 2a15731

Please sign in to comment.