From 4a3349bbad7456f11ac6d1f2c260d9a7a4cb863f Mon Sep 17 00:00:00 2001 From: Clemens Schmid Date: Mon, 11 Nov 2024 09:04:31 +0100 Subject: [PATCH] CDIModel: Refactor report method --- src/cdtools/models/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cdtools/models/base.py b/src/cdtools/models/base.py index d2de6f7..180ba18 100644 --- a/src/cdtools/models/base.py +++ b/src/cdtools/models/base.py @@ -703,11 +703,14 @@ class CDIModel(t.nn.Module): A string with basic info on the latest iteration """ if hasattr(self, 'latest_iteration_time'): - return 'Epoch ' + str(len(self.loss_history)) + \ - ' completed in %0.2f s with loss ' %\ - self.latest_iteration_time + str(self.loss_history[-1]) + epoch = len(self.loss_history) + dt = self.latest_iteration_time + loss = self.loss_history[-1] + msg = f'Epoch {epoch} completed in {dt:0.2f} s with loss {loss:.5e}' else: - return 'No reconstruction iterations performed yet!' + msg = 'No reconstruction iterations performed yet!' + + return msg # By default, the plot_list is empty plot_list = []