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

update LossRecorder to LossOutput #9

Closed
wants to merge 2 commits into from
Closed

Conversation

rpeys
Copy link

@rpeys rpeys commented Jul 11, 2023

this makes mrVI code compatible with updated scvi-tools (see scvi-tools PR#1869 scverse/scvi-tools#1869)

@rpeys
Copy link
Author

rpeys commented Jul 20, 2023

I was just looking back at this PR and realized that I accidentally included a second commit in the PR, [7f0b895] titled "handle no categorical_nuisance_keys." Only the first commit, efc5981, is needed to make the code compatible with the current scvi-tools.

The second commit handles the case where a user does not want to input any nuisance keys. With this update, if no nuisance keys are passed in, the code simply creates a vectors of zeros and treats those as the nuisance keys, which effectively has no impact on the learned latent space since there is only one category.

The one thing that I want to flag for update in the second commit is that you might have a more elegant way of moving this dummy vector onto the GPU. Currently, I just move it on to the same device that the gene expression data is on nuisance_oh = torch.zeros(x.shape[0], 1).to(x.device).

@SamuelCWJ
Copy link

Hi!

I'm getting this error when importing mrvi. Please may I know if I'm doing something wrong? I believe I have installed the latest version of both MrVI and scvi tools.

ImportError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import mrvi

File ~/miniconda3/envs/test1/lib/python3.11/site-packages/mrvi/init.py:8
5 from rich.console import Console
6 from rich.logging import RichHandler
----> 8 from ._model import MrVI, MrVAE
10 # python-poetry/poetry#2366 (comment)
11 # python-poetry/poetry#144 (comment)
12 try:

File ~/miniconda3/envs/test1/lib/python3.11/site-packages/mrvi/_model.py:21
18 from scvi.model.base import UnsupervisedTrainingMixin
19 from scvi.model.base import BaseModelClass, VAEMixin
---> 21 from ._module import MrVAE
22 from ._constants import MRVI_REGISTRY_KEYS
24 logger = logging.getLogger(name)

File ~/miniconda3/envs/test1/lib/python3.11/site-packages/mrvi/_module.py:5
3 import torch.nn as nn
4 from scvi import REGISTRY_KEYS
----> 5 from scvi.module.base import BaseModuleClass, LossRecorder, auto_move_data
6 from scvi.nn import one_hot
7 from torch.distributions import kl_divergence as kl

ImportError: cannot import name 'LossRecorder' from 'scvi.module.base'

Any assistance would be much appreciated! Thank you!

@martinkim0
Copy link
Member

Closing this in favor of #11.

@martinkim0 martinkim0 closed this Oct 12, 2023
@martinkim0
Copy link
Member

@SamuelCWJ The PR I linked above should solve the error you're seeing. I'll be re-releasing after this merges.

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

Successfully merging this pull request may close these issues.

None yet

3 participants