From 42764d18c78653760a8a973abaa4893848e2c787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hendrik=20Schr=C3=B6ter?= Date: Fri, 4 Oct 2019 11:15:19 +0000 Subject: [PATCH] Better error message if no loss was returned from model.training_step() (#294) --- pytorch_lightning/trainer/trainer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index e88750ad25..6b8ed1ea65 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -1156,6 +1156,10 @@ class Trainer(TrainerIO): except Exception: if type(output) is torch.Tensor: loss = output + else: + raise RuntimeError( + 'No `loss` value in the dictionary returned from `model.training_step()`.' + ) # when using dp need to reduce the loss if self.use_dp: