Skip to content

Commit 713e29b

Browse files
authored
Merge pull request #43 from uwsampl/master
Fix complaints about 0-dim tensor
2 parents d5e9033 + 1e52363 commit 713e29b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mnist/train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
acc = correct * 1.0 / len(data)
8686
print('Train Epoch: {} [{}/{}] Loss: {:.6f} Acc: {:.4f} lr: {:.2e}'.format(
8787
epoch, batch_idx * len(data), len(train_loader.dataset),
88-
loss.data[0], acc, optimizer.param_groups[0]['lr']))
88+
loss.data, acc, optimizer.param_groups[0]['lr']))
8989

9090
elapse_time = time.time() - t_begin
9191
speed_epoch = elapse_time / (epoch + 1)
@@ -105,7 +105,7 @@
105105
data, target = data.cuda(), target.cuda()
106106
data, target = Variable(data, volatile=True), Variable(target)
107107
output = model(data)
108-
test_loss += F.cross_entropy(output, target).data[0]
108+
test_loss += F.cross_entropy(output, target).data
109109
pred = output.data.max(1)[1] # get the index of the max log-probability
110110
correct += pred.cpu().eq(indx_target).sum()
111111

0 commit comments

Comments
 (0)