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

Problem loading model #16

Open
jmchan88 opened this issue Aug 9, 2023 · 1 comment
Open

Problem loading model #16

jmchan88 opened this issue Aug 9, 2023 · 1 comment

Comments

@jmchan88
Copy link

jmchan88 commented Aug 9, 2023

Hey ContrastiveVI team!

I'm super excited to try out your method! I ran ContrastiveVI and saved the model, presuming that the model would have similar scVI saving and loading capabilities, as below:

model.save(out_dir + "my_model/")

without any error. But now that I try to load it using:

model = scvi.model.SCVI.load(out_dir + 'n_latent.10/my_model', adata_cv)

I get the following error:

INFO     File                                                                                                      
         /data/peer/chanj3/HTA.fresh_plasticity.SCLC.120122/out.SCLC.ContrastiveVI.120122/n_latent.10/my_model/mode
         l.pt already downloaded                                                                                   
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[28], line 1
----> 1 model = scvi.model.SCVI.load(out_dir + 'n_latent.10/my_model', adata_cv)

File ~/anaconda3/envs/multiome_py_r/lib/python3.10/site-packages/scvi/model/base/_base_model.py:598, in BaseModelClass.load(cls, dir_path, adata, use_gpu, prefix, backup_url)
    596 registry = attr_dict.pop("registry_")
    597 if _MODEL_NAME_KEY in registry and registry[_MODEL_NAME_KEY] != cls.__name__:
--> 598     raise ValueError(
    599         "It appears you are loading a model from a different class."
    600     )
    602 if _SETUP_ARGS_KEY not in registry:
    603     raise ValueError(
    604         "Saved model does not contain original setup inputs. "
    605         "Cannot load the original setup."
    606     )

ValueError: It appears you are loading a model from a different class.

Is there any way to save and load the ContrastiveVI model? Thanks so much!

@ethanweinberger
Copy link
Member

Hey @jmchan88! Sorry for the late reply here. During our experiments we saved/loaded contrastiveVI models using the standard torch.save and torch.load interface, and didn't end up testing out the scvi save/load interface.

We're currently working on moving contrastiveVI over to the scvi-tools codebase (see scverse/scvi-tools#2242), and should have the scvi save/load interface implemented as part of that PR. Please let us know if you have further questions.

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