From 3c7848e9b1525fc87c1201c2a6297fcfa9d9db2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eren=20G=C3=B6lge?= Date: Tue, 19 Oct 2021 16:32:16 +0000 Subject: [PATCH] Don't OOR values in train console log --- TTS/utils/logging/console_logger.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/TTS/utils/logging/console_logger.py b/TTS/utils/logging/console_logger.py index 0c1aa862..74371342 100644 --- a/TTS/utils/logging/console_logger.py +++ b/TTS/utils/logging/console_logger.py @@ -47,11 +47,19 @@ class ConsoleLogger: tcolors.BOLD, step, batch_steps, global_step, tcolors.ENDC ) for key, value in loss_dict.items(): - # print the avg value if given if f"avg_{key}" in avg_loss_dict.keys(): - log_text += "{}{}: {:.5f} ({:.5f})\n".format(indent, key, value, avg_loss_dict[f"avg_{key}"]) + # print the avg value if given + if isinstance(value, float) and round(value, 5) == 0: + # do not round the number if it is zero when rounded + log_text += "{}{}: {} ({})\n".format(indent, key, value, avg_loss_dict[f"avg_{key}"]) + else: + # print the rounded value + log_text += "{}{}: {:.5f} ({:.5f})\n".format(indent, key, value, avg_loss_dict[f"avg_{key}"]) else: - log_text += "{}{}: {:.5f} \n".format(indent, key, value) + if isinstance(value, float) and round(value, 5) == 0: + log_text += "{}{}: {} \n".format(indent, key, value) + else: + log_text += "{}{}: {:.5f} \n".format(indent, key, value) print(log_text, flush=True) # pylint: disable=unused-argument