Better error message if no loss was returned from model.training_step() (#294)

This commit is contained in:
Hendrik Schröter 2019-10-04 11:15:19 +00:00 committed by William Falcon
parent 63c475c600
commit 42764d18c7
1 changed files with 4 additions and 0 deletions

View File

@ -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: