From 4cb8c0c93a98c36ddb309e8668bb7e897ae9e0ee Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 27 Oct 2024 09:19:48 +0100 Subject: [PATCH] [tsa/eval] - fix: ensure matplotlib figures are closed after saving - Prevent a potential memory leak by explicitly closing the plot after saving the image. --- tsa/eval.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tsa/eval.py b/tsa/eval.py index 8bf05a1..50c7583 100644 --- a/tsa/eval.py +++ b/tsa/eval.py @@ -50,6 +50,7 @@ def evaluate(test_iter, criterion, model, config, ts): plt.plot(preds, linewidth=.3) plt.plot(targets, linewidth=.3) plt.savefig("{}/preds.png".format(config.general.output_dir)) + plt.close() torch.save(targets, os.path.join(config.general.output_dir, "targets.pt")) torch.save(predictions, os.path.join(config.general.output_dir, "predictions.pt"))