Question about logging metric object with on_step=True
#14590
-
I have a hard time understanding how logging value through metric object works when using I have these metrics in my lightning module: # for calculating and averaging accuracy across batches
self.train_acc = Accuracy()
# for averaging loss across batches
self.train_loss = MeanMetric() I'm logging metrics on step like this: def training_step(self, batch: Any, batch_idx: int):
loss, preds, targets = self.step(batch)
# update metrics
self.train_loss(loss)
self.train_acc(preds, targets)
self.log("train/loss", self.train_loss, on_step=True, on_epoch=False, prog_bar=True)
self.log("train/acc", self.train_acc, on_step=True, on_epoch=False, prog_bar=True) Question: I'm seeing metric values on the progress bar on each step. Are these values actually accuracy and loss only from current step, or maybe these values are average loss and average accuracy from all steps so far in current epoch? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, the value of |
Beta Was this translation helpful? Give feedback.
Yes, the value of
train/loss=...
shown in the progress bar is calculated based on each step. However, note that the value ofloss=...
(shown by default) at the very left of your progress bar (nottrain/loss=...
) is smoothened across 20 steps. (Related to this RFC #9372)