mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-22 15:42:44 +08:00
code for saving the model is added
This commit is contained in:
@ -13,12 +13,12 @@ batch_size = 100
|
||||
learning_rate = 0.001
|
||||
|
||||
# MNIST Dataset (Images and Labels)
|
||||
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())
|
||||
|
||||
@ -76,4 +76,7 @@ for images, labels in test_loader:
|
||||
total += labels.size(0)
|
||||
correct += (predicted == labels).sum()
|
||||
|
||||
print('Accuracy of the model on the 10000 test images: %d %%' % (100 * correct / total))
|
||||
print('Accuracy of the model on the 10000 test images: %d %%' % (100 * correct / total))
|
||||
|
||||
# Save the Model
|
||||
torch.save(model, 'model.pkl')
|
Reference in New Issue
Block a user