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

How to use pre-trained models on custom datasets #209

Open
GattiMh opened this issue Feb 9, 2023 · 5 comments
Open

How to use pre-trained models on custom datasets #209

GattiMh opened this issue Feb 9, 2023 · 5 comments

Comments

@GattiMh
Copy link

GattiMh commented Feb 9, 2023

Hello!

Many thanks for putting up this code.

I apologise if this is some silly question but I'm new to this field and eager to dive into it.
For the time being, I'm trying to load a pre-trained model and generate predictions for a user defined sets of molecules.
I have found the commands to load a model, which should be something like this:

dataset = Tox21(smiles_to_bigraph, CanonicalAtomFeaturizer()) model = load_pretrained('GCN_Tox21') # Pretrained model loaded model.eval()

What are the commands to generate prediction on user-defined Smiles using the pre-trained model?

Many thanks

@mufeili
Copy link
Contributor

mufeili commented Feb 10, 2023

You might find it helpful to follow the example here.

@GattiMh
Copy link
Author

GattiMh commented Feb 10, 2023

Thank you.

In the Classification_inference.py, there's the -tp as a flag for the train_results_path. So I guess I should use that to load a pre-trained model? It seems it will look for a configure.json which comes as a result of training after classification/regression_train.py.

Apologise for still been confused.

@mufeili
Copy link
Contributor

mufeili commented Feb 11, 2023

Yes. The original classification_inference.py is to be used after you use classification_train.py. You may adapt the file and modify it for your own purpose.

@GattiMh
Copy link
Author

GattiMh commented Feb 11, 2023

Thanks.

But if you want to use pre-trained models then why would you need to use the train.py? I thought you could have used the inference.py just by simply pointing to the folder that contains the pre-trained models.
Am I missing something here?

@mufeili
Copy link
Contributor

mufeili commented Feb 12, 2023

There can be different kinds of pre-trained models. Some models are pre-trained on a particular dataset for a particular supervised learning task. In that scenario, inference.py is designed to use a model pre-trained by using train.py.

There are also models pre-trained on a broad range of datasets in an unsupervised/self-supervised fashion for representation learning. To use this kind of pre-trained models for a particular dataset, it typically requires fine-tuning the pre-trained model on the dataset like what's done in train.py.

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