mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-06 17:44:12 +08:00
delete cuda()
This commit is contained in:
@ -64,7 +64,7 @@ optimizer = torch.optim.Adam(rnn.parameters(), lr=learning_rate)
|
|||||||
for epoch in range(num_epochs):
|
for epoch in range(num_epochs):
|
||||||
for i, (images, labels) in enumerate(train_loader):
|
for i, (images, labels) in enumerate(train_loader):
|
||||||
images = Variable(images.view(-1, sequence_length, input_size))
|
images = Variable(images.view(-1, sequence_length, input_size))
|
||||||
labels = Variable(labels).cuda()
|
labels = Variable(labels)
|
||||||
|
|
||||||
# Forward + Backward + Optimize
|
# Forward + Backward + Optimize
|
||||||
optimizer.zero_grad()
|
optimizer.zero_grad()
|
||||||
@ -90,4 +90,4 @@ for images, labels in test_loader:
|
|||||||
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
|
# Save the Model
|
||||||
torch.save(rnn, 'rnn.pkl')
|
torch.save(rnn, 'rnn.pkl')
|
||||||
|
Reference in New Issue
Block a user