diff --git a/train.py b/train.py index 08e30f09..674e228d 100644 --- a/train.py +++ b/train.py @@ -171,8 +171,9 @@ def train(opt): # Write validation result into summary if tf is not None: add_summary_value(tf_summary_writer, 'validation loss', val_loss, iteration) - for k,v in lang_stats.items(): - add_summary_value(tf_summary_writer, k, v, iteration) + if lang_stats is not None: + for k,v in lang_stats.items(): + add_summary_value(tf_summary_writer, k, v, iteration) tf_summary_writer.flush() val_result_history[iteration] = {'loss': val_loss, 'lang_stats': lang_stats, 'predictions': predictions}