# Pass scvi models to interpretation algorithm for downstream analysis

**URL:** <https://discourse.scverse.org/t/pass-scvi-models-to-interpretation-algorithm-for-downstream-analysis/141>\
**Category:** scvi-tools\
**Tags:** scvi\
**Created:** [July 15, 2021, 4:00am UTC](https://discourse.scverse.org/t/pass-scvi-models-to-interpretation-algorithm-for-downstream-analysis/141 "2021-07-15T04:00:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thisisyichenzhang](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/thisisyichenzhang/32/40_2.png) [@thisisyichenzhang](https://discourse.scverse.org/u/thisisyichenzhang)\
**Post date:** [July 15, 2021, 4:00am UTC](https://discourse.scverse.org/t/pass-scvi-models-to-interpretation-algorithm-for-downstream-analysis/141/1 "2021-07-15T04:00:42Z")

</div>

I have a general question on how to pass the trained scvi models to downstream analysis tools, e.g. Captum (interpretation algorithm for pytorch).  
These tools, e.g., captum, usually accept `nn.module` as input. How can I retrieve the `nn.module` from compact scvi models and pass it to these tools?

Relevant questionss apply to any algorithms taking `nn.module` or `pl.lightningmodule` as input. For example in “weight and bias”, `wandb.watch()` can take `nn.module` or `pl.lightningmodule` to log the gradients and weights during training, which can be useful to diagnose the model, but it is not clear how to do it with scvi models.

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [July 15, 2021, 6:27am UTC](https://discourse.scverse.org/t/pass-scvi-models-to-interpretation-algorithm-for-downstream-analysis/141/2 "2021-07-15T06:27:40Z")

</div>

The underlying `nn.module` is accessible with `model.module`. The pytorch lightning trainer, which contains the pytorch lightning module is accessible with `model.trainer`. In our design, the `nn.module` is passed to a lightning module (which we call a [`TrainingPlan`](https://docs.scvi-tools.org/en/stable/api/reference/scvi.train.TrainingPlan.html), which is then trained with pytorch lightning.)

You can pass any custom callbacks or loggers directly to the pytorch lightning trainer in our model’s train [method](https://docs.scvi-tools.org/en/stable/api/reference/scvi.model.SCVI.train.html#scvi.model.SCVI.train), through `trainer_kwargs`.

I can further clarify any points of confusion, but there should be fairly easy access to regular pytorch lightning features.
