Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load previous-trained model #66

Closed
hereagain-Y opened this issue Feb 24, 2022 · 3 comments
Closed

load previous-trained model #66

hereagain-Y opened this issue Feb 24, 2022 · 3 comments

Comments

@hereagain-Y
Copy link

Hi Dr. John William Sidhom:

Sorry to disturb you, while I have a question about deepTCR. This is an amazing package, and I would like to use it to do sequence-level prediction. So here let us say that I train a model named 'model', and store the middle file at: /user. Then the program will generate a subfolder 'model' and store model checkpoint information there.

My question is, how to load this pre-trained model and do prediction using new data. I saw from website that 'sequence_inference' can 'load previous trained model', but I did not see an example at tutorial. So it will be extremely helpful if you may briefly tell me how to load a model from a pre-generated folder and thus utilize it to do prediction instead of train the model again.

Thanks in advance for your patience and have a great day!

@sidhomj
Copy link
Owner

sidhomj commented Feb 24, 2022

You can see an example of how to do inference in the tutorial under VAE inference. It should work in the same way. You instantiate a DeepTCR object with the name of the model and then run Sequence_Inference method on your data.

https://github.com/sidhomj/DeepTCR/blob/master/tutorials/unsupervised/8%20-%20VAE%20Inference.ipynb

https://sidhomj.github.io/DeepTCR/api/#DeepTCR.DeepTCR.DeepTCR_base.Sequence_Inference

Hope this helps!

@hereagain-Y
Copy link
Author

Hi Dr. John William Sidhom:

Thanks for your quick response! I am sorry that I may not explain my question clearly. I went through the tutorial, and I feel like the model training and sequence inference is in the same script. In the previous step I trained a model, and in the second step I do inference using previouslt trained model.

Now suppose I want to write two scripts. In the first script, I trained a model called 'modelA', and store all middle-model-checkpoint files it at /user. Then I quit this script, and initialize another program. Now the previous modelA does not exists in the python interface, but the middle-model-checkpoint files are still there under /user. So instead of train this model again, and call the model to do inference, is there anyway to load the middle-model-checkpoint files from /user, git it a name and use it to do sequence inference?

@sidhomj
Copy link
Owner

sidhomj commented Feb 25, 2022

You simply instantiate the object with the name of the model and then run the inference method you want.

DTCR = DeepTCR_SS('modelA')
DTCR.Sequence_Inference(*args)

@sidhomj sidhomj closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants