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

create setup and remove @nn.compact #1403

Merged
merged 9 commits into from
Mar 7, 2022
Merged

create setup and remove @nn.compact #1403

merged 9 commits into from
Mar 7, 2022

Conversation

mjayasur
Copy link
Contributor

@mjayasur mjayasur commented Mar 4, 2022

Fixes #1402

@mjayasur mjayasur requested a review from adamgayoso March 4, 2022 16:34
self.dense2 = Dense(self.n_hidden)
self.dense3 = Dense(self.n_hidden)
self.dense4 = Dense(self.n_input)

def __call__(self, z: jnp.ndarray, batch: jnp.ndarray, is_training: bool):
disp = self.param(
"disp", lambda rng, shape: jax.random.normal(rng, shape), (self.n_input, 1)
)
is_training = nn.merge_param("is_training", self.is_training, is_training)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can get rid of these lines and move all the layers into setup (including batch norm and dropout).

@@ -104,7 +114,9 @@ class JaxVAE(nn.Module):
gene_likelihood: str = "nb"
eps: float = 1e-8

@nn.compact
def setup(self):
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's implement this one too

@codecov
Copy link

codecov bot commented Mar 7, 2022

Codecov Report

Merging #1403 (9905a03) into master (dac2589) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1403      +/-   ##
==========================================
+ Coverage   90.99%   91.01%   +0.01%     
==========================================
  Files         111      111              
  Lines        8614     8633      +19     
==========================================
+ Hits         7838     7857      +19     
  Misses        776      776              
Impacted Files Coverage Δ
scvi/module/_jaxvae.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dac2589...9905a03. Read the comment docs.

@adamgayoso adamgayoso enabled auto-merge (squash) March 7, 2022 18:04
@adamgayoso adamgayoso merged commit a5a7c59 into master Mar 7, 2022
@adamgayoso adamgayoso deleted the jax_setup_fix branch March 7, 2022 19:42
meeseeksmachine pushed a commit to meeseeksmachine/scvi-tools that referenced this pull request Mar 7, 2022
adamgayoso pushed a commit that referenced this pull request Mar 7, 2022
nrclaudio pushed a commit to nrclaudio/scvi-tools-tune that referenced this pull request Jun 21, 2022
* create setup and remove @nn.compact

* Add dummy setup

* add to all

* fixes

* move param

* fix

* add release note

Co-authored-by: adamgayoso <[email protected]>
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.

Use setup instead of nn.compact for Flax
2 participants