Accuracy doesn't show up in progress bar #11277
Answered
by
awaelchli
lastadreamer
asked this question in
Lightning Trainer API: Trainer, LightningModule, LightningDataModule
-
class Mynet(pl.LightningModule)
... ...
def training_step(self, batch, batch_idx):
x, y = batch
logits = self(x)
loss = F.nll_loss(logits, y)
accu = ((torch.argmax(logits, dim=1) == y).sum()/x.shape[0]).item()
return {'loss':loss, 'accuracy':accu} i define training_step like this, the progress bar show loss, but not show accu. pytorch_lightning.version = 1.5.7 |
Beta Was this translation helpful? Give feedback.
Answered by
awaelchli
Dec 31, 2021
Replies: 1 comment
-
You need to log it: self.log("accuracy", accu, prog_bar=True)
return {'loss':loss} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
awaelchli
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to log it:
Docs: https://pytorch-lightning.readthedocs.io/en/latest/extensions/logging.html#logging-from-a-lightningmodule