gablg1 / organ Goto Github PK
View Code? Open in Web Editor NEWObjective-Reinforced Generative Adversarial Networks (ORGAN) for Sequence Generation Models
License: GNU General Public License v2.0
Objective-Reinforced Generative Adversarial Networks (ORGAN) for Sequence Generation Models
License: GNU General Public License v2.0
When running train_ogan.py:
File "train_ogan.py", line 19, in
import music_metrics
File "~/objective_gan/ObjectiveGAN/model/music_metrics.py", line 12, in
import editdistance
ImportError: No module named 'editdistance'
I am trying to reproduce the results given in the CSV files.
For the training set, I used 'ORGAN-master/data/drugs_sub.smi' which contains 15k SMILES (probably the Drugs-like dataset from ZINC).
However, results do not coincide with those in the CSV files (although they are near). For example, for generated SMILES in 'ORGAN-master/results/mol_results/drugs_00_drug-candidate', you announce, for diversity:
batch 197: 0.3459632353
batch 198: 0.2288000541
batch 199: 0.2550336591
But I find:
batch 197: 0.28610357401436792
batch 198: 0.27172717539688912
batch 199: 0.23757408323392681
I guess you provided other SMILES than those used for the tests. Did you keep the original training sets?
ValueError Traceback (most recent call last)
Cell In[2], line 5
3 model.set_training_program(['novelty'], [1])
4 model.load_metrics()
----> 5 model.train(ckpt_dir='ckpt')
File /home2/bej22/projects/druglikeness/new/ORGAN/organ/init.py:750, in ORGAN.train(self, ckpt_dir)
747 if not self.PRETRAINED and not self.SESS_LOADED:
749 self.sess.run(tf.global_variables_initializer())
--> 750 self.pretrain()
752 if not os.path.exists(ckpt_dir):
753 os.makedirs(ckpt_dir)
File /home2/bej22/projects/druglikeness/new/ORGAN/organ/init.py:696, in ORGAN.pretrain(self)
686 #print(dis_batches)
687 #print(dis_x_train)
688 #print(dis_y_train)
(...)
693 #print(np.hstack((dis_x_train,dis_y_train)).shape)
694 # print(np.array(list(zip(dis_x_train, dis_y_train))).shape)
695 supervised_d_losses = []
--> 696 for batch in dis_batches:
697 print(batch.shape)
698 x_batch, y_batch = zip(*batch)
File /home2/bej22/projects/druglikeness/new/ORGAN/organ/data_loaders.py:89, in Dis_Dataloader.batch_iter(self, data, batch_size, num_epochs)
85 def batch_iter(self, data, batch_size, num_epochs):
86 """
87 Generates a batch iterator for a dataset.
88 """
---> 89 data = np.array(list(data))
90 data_size = len(data)
91 print(data_size)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (3868, 2) + inhomogeneous part.
How do you compute Druglikeness in the paper?
Page 5, you say that Druglikeness is composed of a linear combination of Novelty, Diversity, Solubility and Synthetizability, without specifying the coefficients of this linear combination.
In the code (line 313 of mol_metrics.py), druglikeness seems to be the arithmetic mean of those parameters. However, this formula fails to give the figures announced in the paper.
To figure out those coefficients, I tried to solve the linear system of equations (with just 8 equations), but it is impossible again to find a solution. Can you provide clarifications please?
I finished training, but I can't seem to where the generated sample are, or were they ever saved?
First Thank you for update ORGAN!
in the recent logP update the ValueError you set, 0.0, is a "normal/right" value!
have a look:
low_logp = -2.12178879609
high_logp = 6.0429063424
logp = Crippen.MolLogP(Chem.MolFromSmiles(smile))
val = remap(logp, low_logp, high_logp)
val = np.clip(val, 0.0, 1.0)
return val
return 0.0
-2.12 < 0.0 < 6.04
using this setting to train a set of smiles will end up all bad smiles because the value 0.0 is a "good" reward!
Maybe we can filter out bad smiles before calling logP?
i think the data in your paper are fake!
Hi, thank you for this great work.
After training the model, how can we load it again and reuse it for generating new molecules (e.g. SMILES)? I hope you can tell me how write a program for reusing it, thanks in advance
I don't understand how the folder 'mol_results' is organized: I am looking for the SMILES generated by your experiments mentioned in your paper, for Naive RL, ORGAN with lambda=0.8, and SeqGAN.
There are files with lists of SMILES, but the model that generated them is not mentioned anywhere.
I encountered an error
Traceback (most recent call last):
File "example.py", line 11, in <module>
model.train(ckpt_dir='ckpt')
File "/home/deepest/ORGAN/organ/__init__.py", line 813, in train
batch_reward, self.LAMBDA)
File "/home/deepest/ORGAN/organ/rollout.py", line 119, in get_reward
rew = reward_fn(generated_seqs)
File "/home/deepest/ORGAN/organ/__init__.py", line 786, in batch_reward
pct_unique = len(list(set(decoded))) / float(len(decoded))
TypeError: unhashable type: 'list'
When running,I have an error:
Traceback (most recent call last):
File "example.py", line 8, in
model.train(ckpt_dir='ckpt')
File "/home/zy/ORGAN/ORGAN-master/organ/init.py", line 745, in train
self.pretrain()
File "/home/zy/ORGAN/ORGAN-master/organ/init.py", line 670, in pretrain
_, g_loss, g_pred = self.generator.pretrain_step(self.sess,batch)
File "/home/zy/ORGAN/ORGAN-master/organ/generator.py", line 210, in pretrain_step
outputs = session.run([self.pretrain_updates,self.pretrain_loss,self.g_predictions],
File "/home/zy/.conda/envs/zy_2/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 967, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File "/home/zy/.conda/envs/zy_2/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1166, in _run
np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)#np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
File "/home/zy/.local/lib/python3.8/site-packages/numpy/core/_asarray.py", line 83, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Any solutions?
Thank you for your answer.
When running,I have an error:
Traceback (most recent call last):
File "example.py", line 9, in
model.train(ckpt_dir='ckpt')
File "D:\mypy\ORGAN-master\organ_init_.py", line 763, in train
gen_samples, self.train_samples, self.ord_dict, results)
File "D:\mypy\ORGAN-master\organ\mol_metrics.py", line 185, in compute_results
results[objective] = np.mean(reward(verified_samples, train_data))
File "D:\mypy\ORGAN-master\organ_init_.py", line 743, in batch_reward
for sample in samples]
File "D:\mypy\ORGAN-master\organ_init_.py", line 743, in
for sample in samples]
File "D:\mypy\ORGAN-master\organ\mol_metrics.py", line 117, in decode
''.join([ord_dict[o] for o in ords]))
File "D:\mypy\ORGAN-master\organ\mol_metrics.py", line 117, in
''.join([ord_dict[o] for o in ords]))
KeyError: 'O'
When running:
python train_ogan.py exp.json
I have an error:
`Start pre-training...
0%| | 0/240 [00:00<?, ?it/s] gen pre-train
test_loss 5.93523359299, train_loss 2.64412474632
/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py:2909: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
Traceback (most recent call last):
File "train_ogan.py", line 379, in
main()
File "train_ogan.py", line 309, in main
pretrain(sess, generator, target_lstm, train_discriminator)
File "train_ogan.py", line 193, in pretrain
mm.compute_results(samples, train_samples, ord_dict, results)
File "/home/mostafa/Desktop/ORGAN-master/model/mol_metrics.py", line 176, in compute_results
results[objective] = np.mean(func(verified_samples, train_data))
File "/home/mostafa/Desktop/ORGAN-master/model/mol_metrics.py", line 231, in batch_diversity
m, 4, nBits=2048) for m in rand_mols]
Boost.Python.ArgumentError: Python argument types in
rdkit.Chem.rdMolDescriptors.GetMorganFingerprintAsBitVect(NoneType, int)
did not match C++ signature:
GetMorganFingerprintAsBitVect(RDKit::ROMol mol, int radius, unsigned int nBits=2048, boost::python::api::object invariants=[], boost::python::api::object fromAtoms=[], bool useChirality=False, bool useBondTypes=True, bool useFeatures=False, boost::python::api::object bitInfo=None)
`
Hi @couteiral,
In init.py, there are two times to call mm.apply_to_valid, however, I couldn't find def apply_to_valid in neither molecule_metrics.py nor music_metrics.py!
Did I miss something?
Please let me know.
Thanks!
Toushi68
is it possible to use WGAN-GP for D?
Dumb question, the code run on GPU or only in CPU? I running the code on GCloud VM Machine and don't saw if the GPU is utilised. I need reconfigure the code to use the GPU?
Adding tqdm to the requirements.txt will probably fix the issue. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.