<jupyter_start><jupyter_text>Saving Models<jupyter_code>torch.save(model.state_dict(), "model.pth")
print("Saved PyTorch Model State to model.pth")<jupyter_output>Saved PyTorch Model State to model.pth<jupyter_text>Loading Models<jupyter_code>model = NeuralNetwork()
model.load_state_dict(torch.load("model.pth"))
classes = [
    "T-shirt/top",
    "Trouser",
    "Pullover",
    "Dress",
    "Coat",
    "Sandal",
    "Shirt",
    "Sneaker",
    "Bag",
    "Ankle boot",
]

model.eval()
x, y = test_data[0][0], test_data[0][1]
with torch.no_grad():
    pred = model(x)
    predicted, actual = classes[pred[0].argmax(0)], classes[y]
    print(f'Predicted: "{predicted}", Actual: "{actual}"')<jupyter_output>Predicted: "Sandal", Actual: "Ankle boot"
{'fraction_non_alphanumeric': 0.17647058823529413, 'fraction_numerical': 0.008021390374331552, 'mean_word_length': 5.0894308943089435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '223496', 'license': 'Apache-2.0', 'n_tokens_mistral': 303, 'n_tokens_neox': 302, 'n_words': 50, 'path': 'pytorch/tutorial/quickstart.ipynb', 'repo_name': 'K-ona/template', 'size': '748'}