mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-28 04:23:18 +08:00
code for saving the model is added
This commit is contained in:
@ -16,12 +16,12 @@ num_epochs = 2
|
||||
learning_rate = 0.003
|
||||
|
||||
# MNIST Dataset
|
||||
train_dataset = dsets.MNIST(root='./data/',
|
||||
train_dataset = dsets.MNIST(root='../data/',
|
||||
train=True,
|
||||
transform=transforms.ToTensor(),
|
||||
download=True)
|
||||
|
||||
test_dataset = dsets.MNIST(root='./data/',
|
||||
test_dataset = dsets.MNIST(root='../data/',
|
||||
train=False,
|
||||
transform=transforms.ToTensor())
|
||||
|
||||
@ -88,4 +88,7 @@ for images, labels in test_loader:
|
||||
total += labels.size(0)
|
||||
correct += (predicted.cpu() == labels).sum()
|
||||
|
||||
print('Test Accuracy of the model on the 10000 test images: %d %%' % (100 * correct / total))
|
||||
print('Test Accuracy of the model on the 10000 test images: %d %%' % (100 * correct / total))
|
||||
|
||||
# Save the Model
|
||||
torch.save(rnn, 'rnn.pkl')
|
Reference in New Issue
Block a user