Can training step return dictionary? #8153
-
My training_step returns {‘loss’: loss, ‘num’: len(batch)}, so I could calculate mean loss at the end of epoch. But now I get this warning, that my training_step returns None and loss doesn't display in the progress bar. How can I return dict from training_step and display loss in the progress bar at the same tim? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, check the doc of
just return dict like what you do now and use
BTW, If you just want mean loss, I think pytorch_lightning have already done for you and you don't need to modified training_step_end(not sure) |
Beta Was this translation helpful? Give feedback.
Yes, check the doc of
LightningModule.training_step
.just return dict like what you do now and use
self.log(loss, prog_bar=True)
to display loss in prog_bar.BTW, If you just want mean loss, I think pytorch_lightning have already done for you and you don't need to modified training_step_end(not sure)