From 367a5cc9ffc8dfa31505618ec83053aa41be7b69 Mon Sep 17 00:00:00 2001 From: cozy-hn Date: Fri, 24 Nov 2023 03:40:34 +0900 Subject: [PATCH 1/6] change "plot_loss_history" because of safety --- deepxde/utils/external.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index bca1cc1d1..43cc51134 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -192,8 +192,8 @@ def plot_loss_history(loss_history, fname=None): fname (string): If `fname` is a string (e.g., 'loss_history.png'), then save the figure to the file of the file name `fname`. """ - loss_train = np.sum(loss_history.loss_train, axis=1) - loss_test = np.sum(loss_history.loss_test, axis=1) + loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) + loss_test = np.array([np.sum(loss) for loss in loss_history.loss_test]) plt.figure() plt.semilogy(loss_history.steps, loss_train, label="Train loss") From 43702123a4235ce093f3204c4554711b18db7d30 Mon Sep 17 00:00:00 2001 From: Jiheun Ko Date: Sun, 26 Nov 2023 04:27:48 +0900 Subject: [PATCH 2/6] change plot_loss_history because of safety --- deepxde/utils/external.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index 43cc51134..4e86969ea 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -192,8 +192,15 @@ def plot_loss_history(loss_history, fname=None): fname (string): If `fname` is a string (e.g., 'loss_history.png'), then save the figure to the file of the file name `fname`. """ + + """Updated loss calculations to handle irregular array sizes. + Previous method with np.sum was error-prone for arrays of varying lengths. + + loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) + """ loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) loss_test = np.array([np.sum(loss) for loss in loss_history.loss_test]) + plt.figure() plt.semilogy(loss_history.steps, loss_train, label="Train loss") From e20ff7ead4c2128904426d8bded9f723fb6f4c64 Mon Sep 17 00:00:00 2001 From: Jiheun Ko Date: Sun, 26 Nov 2023 04:31:46 +0900 Subject: [PATCH 3/6] change plot_loss_history because of safety --- deepxde/utils/external.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index 4e86969ea..3bd1dfa02 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -193,11 +193,8 @@ def plot_loss_history(loss_history, fname=None): figure to the file of the file name `fname`. """ - """Updated loss calculations to handle irregular array sizes. - Previous method with np.sum was error-prone for arrays of varying lengths. - - loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) - """ + # Updated loss calculations to handle irregular array sizes. + # Previous method with np.sum was error-prone for arrays of varying lengths. loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) loss_test = np.array([np.sum(loss) for loss in loss_history.loss_test]) From a44400addfa9f8c3db703463f0b58974f22a3377 Mon Sep 17 00:00:00 2001 From: Jiheun Ko Date: Sun, 26 Nov 2023 04:53:20 +0900 Subject: [PATCH 4/6] change plot_loss_history because of safety --- deepxde/utils/external.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index 3bd1dfa02..c00179902 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -193,8 +193,8 @@ def plot_loss_history(loss_history, fname=None): figure to the file of the file name `fname`. """ - # Updated loss calculations to handle irregular array sizes. - # Previous method with np.sum was error-prone for arrays of varying lengths. + # np.sum(loss_history.loss_train, axis=1) is error-prone for arrays of varying lengths. + # Handle irregular array sizes. loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) loss_test = np.array([np.sum(loss) for loss in loss_history.loss_test]) From cfeea0134b83cf62acc948140ca100c883a84946 Mon Sep 17 00:00:00 2001 From: Jiheun Ko Date: Sun, 26 Nov 2023 05:06:29 +0900 Subject: [PATCH 5/6] change plot_loss_history because of safety --- deepxde/utils/external.py | 1 - 1 file changed, 1 deletion(-) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index c00179902..b5c39abbc 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -197,7 +197,6 @@ def plot_loss_history(loss_history, fname=None): # Handle irregular array sizes. loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train]) loss_test = np.array([np.sum(loss) for loss in loss_history.loss_test]) - plt.figure() plt.semilogy(loss_history.steps, loss_train, label="Train loss") From ff0dd62ec3e0f5041e9473f32f61bb1fd099a1ca Mon Sep 17 00:00:00 2001 From: Jiheun Ko Date: Sun, 26 Nov 2023 05:07:22 +0900 Subject: [PATCH 6/6] change plot_loss_history because of safety --- deepxde/utils/external.py | 1 - 1 file changed, 1 deletion(-) diff --git a/deepxde/utils/external.py b/deepxde/utils/external.py index b5c39abbc..2e3a3bc5f 100644 --- a/deepxde/utils/external.py +++ b/deepxde/utils/external.py @@ -192,7 +192,6 @@ def plot_loss_history(loss_history, fname=None): fname (string): If `fname` is a string (e.g., 'loss_history.png'), then save the figure to the file of the file name `fname`. """ - # np.sum(loss_history.loss_train, axis=1) is error-prone for arrays of varying lengths. # Handle irregular array sizes. loss_train = np.array([np.sum(loss) for loss in loss_history.loss_train])