Autotune on custom model class

Hi there,
I am trying to use the scvi.autotune module on a custom model class based on BaseModelClass. I’ve followed the tutorial and I am able to use the TunableMixin to customize the set of tunable parameters, but not for exposing additional metrics.

Can I use the mixin to expose more metrics? I would like to use other metrics reported in the training history for tuning (e.g. elbo_validation).

Thanks in advance!

Hi, can you please use the current main? I inherited it from Martin and this seems more straightforward to me. Is it a metric that is anyhow tracked by your model (I assume so as you mention the model history) or do you want to have a custom callback to track another metric. First one is easy by passing in a list of metrics to run_autotune in scvi-tools/src/scvi/autotune/_tune.py at main · scverse/scvi-tools · GitHub

An example for the second one, you can find at: Comparing main...metrics · scverse/scvi-tools · GitHub (it is pretty involved to set it up), so if you think it’s of general use, we can provide some help to set up a new Callback.

Thank you @cane11 for the quick reply!
I switched to the implementation in main and that does exactly what I need, to use another regularly tracked metric). I also agree that this implementation looks more straightforward than the one in the tutorial.

Great and thanks for the feedback. Release will be in the next weeks.