Getting the parameters and their names of scVI

Hi,
I used to use model.named_parameters in pytorch to get the model’s parameters and their names. I found the analogous in scvi

scvi.module.SCANVAE.named_parameters

but I could not understand the provided example

for name, param in self.named_parameters():
if name in [‘bias’]:
print(param.size())

I am not sure how to use it to get the parameters of the scVI model I am using. For example, I am calling the scVI model ‘MODEL’. How can I get the ‘MODEL’ parameters and their names?

Thanks in advance :slight_smile:

You want to do something like

model = scvi.model.SCVI(adata)
model.module # this is a pytorch module
model.module.named_parameters()

Hi, I am trying to trace back the parameters set during scvi_model.train(). Is there a way to retrieve this information from the trained model? Specifically, I want to confirm whether I had set parameters like batch_size, max_epochs, and early_stopping during training. Because, I suspect I may have modified some code in the notebook.

No these are not stored and once trained you can’t look them up. You can call train on an existing model several times. This would lead to inconsistencies. We store however the indices of train and validation cells (in adata.obs) as well as the learning rate and kl_weight if these are adjusted during model training (adoptive lr or kl warmup).