# Difference between \`TrainingPlan.log()\` vs \`TrainingPlan.compute\_and\_log\_metrics()\`?

**URL:** <https://discourse.scverse.org/t/difference-between-trainingplan-log-vs-trainingplan-compute-and-log-metrics/764>\
**Category:** scvi-tools\
**Tags:** scvi, developer\
**Created:** [September 20, 2022, 11:11pm UTC](https://discourse.scverse.org/t/difference-between-trainingplan-log-vs-trainingplan-compute-and-log-metrics/764 "2022-09-20T23:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/mkarikom/32/136_2.png) [@mkarikom](https://discourse.scverse.org/u/mkarikom)\
**Post date:** [September 20, 2022, 11:11pm UTC](https://discourse.scverse.org/t/difference-between-trainingplan-log-vs-trainingplan-compute-and-log-metrics/764/1 "2022-09-20T23:11:47Z")

</div>

What is the difference between `TrainingPlan.log()` and `TrainingPlan.compute_and_log_metrics()`?

In `scvi.train.TraniningPlan`, it looks like `self.log()` just records a subset (the average reconstruction loss) of the stuff recorder by `self.compute_and_log_metrics()` but I’m confused about which one of these satisfies the [LightningModule.training\_step() pattern to return a loss](https://pytorch-lightning.readthedocs.io/en/stable/common/lightning_module.html) to the trainer?

---

<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:** [October 5, 2022, 11:09pm UTC](https://discourse.scverse.org/t/difference-between-trainingplan-log-vs-trainingplan-compute-and-log-metrics/764/2 "2022-10-05T23:09:36Z")

</div>

`self.log()` is just logging the loss and all the other stuff is there to log the output of `LossRecorder`, which computes the ELBO automatically and records any other stored metrics.
