Fix incorrect handling of on_batch_end edge cases in run_training_batch (#509)

* Fix returning only 2 values on an early exit. 

This fixes a bug 

`ValueError: not enough values to unpack (expected 3, got 2)`

* Update train_loop_mixin.py

* Change to return dict

The return value was actually a dict even though that variable is initialized as a list.
This commit is contained in:
Jeffrey Ling
2019-11-19 15:38:54 -08:00
committed by William Falcon
parent 277fd2f74a
commit 619143a734
@@ -155,7 +155,7 @@ class TrainerTrainLoopMixin(object):
all_log_metrics = []
if batch is None:
return 0, grad_norm_dic
return 0, grad_norm_dic, {}
# hook
if self.is_function_implemented('on_batch_start'):
@@ -163,7 +163,7 @@ class TrainerTrainLoopMixin(object):
response = model_ref.on_batch_start(batch)
if response == -1:
return -1, grad_norm_dic
return -1, grad_norm_dic, {}
splits = [batch]
if self.truncated_bptt_steps is not None: