Skip to content

Commit 4cb8c0c

Browse files
author
Jules
committed
[tsa/eval] - fix: ensure matplotlib figures are closed after saving
- Prevent a potential memory leak by explicitly closing the plot after saving the image.
1 parent b5bc494 commit 4cb8c0c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tsa/eval.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def evaluate(test_iter, criterion, model, config, ts):
5050
plt.plot(preds, linewidth=.3)
5151
plt.plot(targets, linewidth=.3)
5252
plt.savefig("{}/preds.png".format(config.general.output_dir))
53+
plt.close()
5354

5455
torch.save(targets, os.path.join(config.general.output_dir, "targets.pt"))
5556
torch.save(predictions, os.path.join(config.general.output_dir, "predictions.pt"))

0 commit comments

Comments
 (0)