From a4f072d08a1258fe4a4bf33b73bac30ac2e0ca4d Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Fri, 3 Sep 2021 11:32:55 -0500 Subject: Save model to file and generate images --- accuracy.png | Bin 0 -> 21588 bytes loss.png | Bin 0 -> 36478 bytes mnist.py | 8 ++++++-- model.pth | Bin 2680919 -> 5907689 bytes 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 accuracy.png create mode 100644 loss.png diff --git a/accuracy.png b/accuracy.png new file mode 100644 index 0000000..4d04a64 Binary files /dev/null and b/accuracy.png differ diff --git a/loss.png b/loss.png new file mode 100644 index 0000000..8a9eca4 Binary files /dev/null and b/loss.png differ diff --git a/mnist.py b/mnist.py index 4466052..8ab8614 100644 --- a/mnist.py +++ b/mnist.py @@ -113,14 +113,18 @@ for epoch in range(num_epochs): print("Iteration: {}, Loss: {}, Accuracy: {}%".format(count, loss.data, accuracy)) +torch.save(model.state_dict(), "model.pth") +print("Saved PyTorch Model State to model.pth") + + plt.plot(iteration_list, loss_list) plt.xlabel("No. of Iteration") plt.ylabel("Loss") plt.title("Iterations vs Loss") -plt.show() +plt.savefig("loss.png") plt.plot(iteration_list, accuracy_list) plt.xlabel("No. of Iteration") plt.ylabel("Accuracy") plt.title("Iterations vs Accuracy") -plt.show() +plt.savefig("accuracy.png") diff --git a/model.pth b/model.pth index 195525e..d0a1381 100644 Binary files a/model.pth and b/model.pth differ -- cgit v1.2.3-70-g09d2