Closed albertma-evotec closed 4 years ago
Hi,
Pytorch keeps track of the gradients during the training and therefore we can use the backpropagation algorithm to optimize the weights (https://pytorch.org/docs/stable/optim.html). The model.sample method converts the pytorch tensor to a numpy array (model/bimodal.py line 271). To re-train the model, you have to directly work with the model._lstm output (see also model/bimodal.py line 215) and define your loss function using pytorch tensors.
I am not sure if it solves the problem entirely but it might give you some hints.
Thanks, I will try.
First of all I am sorry for following question being a bit irrelevant to this project but I am looking for some guidance and jump start.
I am trying to add some code to apply reinforcement learning on the pre-trained BIMODAL model to do multi-parameter optimization. I am using the pretrained model under /evaluation/BIMODAL_random_512_FineTuning_template folder
I am basically trying to do something similar to the published REINVENT network https://arxiv.org/abs/1704.07555 (Olivercrona et. al., 2017) https://github.com/MarcusOlivecrona/REINVENT
but I am not sure where to start to define and update a proper loss function based on the reward/scoring function of the generated structures (e.g. maximizing a penalised logP and QED, etc.). I know my reward function, for simplicity, let's say it is the QED and I am trying to generate compounds that maximise this score.
For the moment, I just define my loss as the MSE loss: (I doubt it is the correct approach though, but I am not sure what else I can do. I am not even sure I should use MSE loss. Maybe I need to consider something like the logits and likelihoods?)
I re-trained the model for 200 steps but no improvement of the score/reward.
Would you mind giving me some guidance please? I know it is a long question but thank you very much in advance.
This is the my code to try to re-train the pre-trained model with reinforcement learning