Skip to content

Commit

Permalink
[tsa/eval] - fix: ensure matplotlib figures are closed after saving
Browse files Browse the repository at this point in the history
 - Prevent a potential memory leak by explicitly closing the plot after saving the image.
  • Loading branch information
Jules committed Oct 27, 2024
1 parent b5bc494 commit 4cb8c0c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tsa/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 4cb8c0c

Please sign in to comment.