-
Notifications
You must be signed in to change notification settings - Fork 2
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
Include MoG and ConditionalNorms. #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some small questions about the implementation
cat_dim: int | None = None, | ||
conditional: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It currently fails. Can you add something like batch_key (it's the site in mrVI) and ConditionalNorm is only computed on this. It would be 'assay_suspension' for census.
if self.prior=='mog': | ||
self.register_buffer( | ||
"u_prior_logits", torch.ones([mixture_components])) | ||
self.register_buffer( | ||
"u_prior_means", torch.randn([n_latent, mixture_components])) | ||
self.register_buffer( | ||
"u_prior_scales", torch.zeros([n_latent, mixture_components])) | ||
elif self.prior=='mog_celltype': | ||
self.register_buffer( | ||
"u_prior_logits", torch.ones([n_labels])) | ||
self.register_buffer( | ||
"u_prior_means", torch.randn([n_latent, n_labels])) | ||
self.register_buffer( | ||
"u_prior_scales", torch.zeros([n_latent, n_labels])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these parameters updated during model training?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they are learnable and are updated in my hands.
# (n_obs, n_latent) -> (n_obs,) | ||
kl_div = dist.kl_divergence(posterior, prior).sum(dim=-1) | ||
if self.prior=='mog' or self.prior=='mog_celltype': | ||
u = posterior.rsample(sample_shape=(10,)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the sample shape as a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially, in mrVI we fixed it. We should then expose it through model.train.
def forward(self, x, y): | ||
out = self.bn(x) | ||
gamma, beta = self.embed(y.long().ravel()).chunk(2, 1) | ||
out = gamma.view(-1, self.num_features) * out + beta.view(-1, self.num_features) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the .view() thing is needed anymore?
out = gamma.view(-1, self.num_features) * out + beta.view(-1, self.num_features) | |
out = gamma * out + beta |
def forward(self, x, y): | ||
out = self.ln(x) | ||
gamma, beta = self.embed(y.long().ravel()).chunk(2, 1) | ||
out = gamma.view(-1, self.num_features) * out + beta.view(-1, self.num_features) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
No description provided.