'ys.detach().numpy() -> ys.cpu().detach().numpy()'
@@ -107,7 +107,7 @@ def mnist_tutorial(nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE,
optimizer.step() # update gradients
preds_np = preds.cpu().detach().numpy()
- correct += (np.argmax(preds_np, axis=1) == ys.detach().numpy()).sum()
+ correct += (np.argmax(preds_np, axis=1) == ys.cpu().detach().numpy()).sum()
total += train_loader.batch_size
step += 1
if total % 1000 == 0:
@@ -127,7 +127,7 @@ def mnist_tutorial(nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE,
preds = torch_model(xs)
preds_np = preds.cpu().detach().numpy()
- correct += (np.argmax(preds_np, axis=1) == ys.detach().numpy()).sum()
+ correct += (np.argmax(preds_np, axis=1) == ys.cpu().detach().numpy()).sum()
total += len(xs)
acc = float(correct) / total
@@ -155,7 +155,7 @@ def mnist_tutorial(nb_epochs=NB_EPOCHS, batch_size=BATCH_SIZE,
correct = 0
for xs, ys in test_loader:
adv_preds = sess.run(adv_preds_op, feed_dict={x_op: xs})
- correct += (np.argmax(adv_preds, axis=1) == ys.detach().numpy()).sum()
+ correct += (np.argmax(adv_preds, axis=1) == ys.cpu().detach().numpy()).sum()
total += test_loader.batch_size
acc = float(correct) / total
