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

Loading whole model #191

Closed
eschlager opened this issue Sep 22, 2023 · 3 comments
Closed

Loading whole model #191

eschlager opened this issue Sep 22, 2023 · 3 comments
Assignees
Labels
question Further information is requested stale

Comments

@eschlager
Copy link

1. Feature description

How to load a trained model, without initialising the class beforehand manually?
Since save_model saves the whole model and not only model.state_dict(), the model setup is saved I guess - but I don't know how to load it?

The tutorials only show loading the model after it was initalised previously already.

2. Motivation

After initialising SAITS model, the trained weights can be loaded using saits.load_model(dir).
However, to initialise the model correctly, you need to know n_steps, n_features, etc. before loading the model.

3. Your contribution

I tired loading the model using saits = torch.load(directory).

This loads the module _SAITS.

Running imputation then gives the error AttributeError: '_SAITS' object has no attribute 'impute'.

@eschlager eschlager added enhancement New feature or request new feature Proposing to add a new feature labels Sep 22, 2023
@WenjieDu
Copy link
Owner

Please read the doc https://docs.pypots.com/en/latest/pypots.imputation.html#pypots.imputation.saits.SAITS.load_model. Each model in PyPOTS has both functions save_model() and load_model(). After your training, you will find the trained model file saved by PyPOTS. To reload it, you need to initialize a model with the same model hyperparameters, then run model.load_model(path_to_your_saved_model_file).

@WenjieDu
Copy link
Owner

BTW, if you think SAITS and PyPOTS are useful to your work, please star🌟 them on GitHub and cite them properly in your research 😊 Thank you, Elke! This means a lot to our open-science work.

@WenjieDu WenjieDu added question Further information is requested and removed enhancement New feature or request new feature Proposing to add a new feature labels Sep 24, 2023
@WenjieDu WenjieDu self-assigned this Sep 24, 2023
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

This issue had no activity for 14 days. It will be closed in 1 week unless there is some new activity. Is this issue already resolved?

@github-actions github-actions bot added the stale label Oct 9, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

2 participants