Skip to content

Commit 78e3873

Browse files
committed
intro to pytorch: Part 2, next() is not a method
1 parent c9404fc commit 78e3873

5 files changed

+6
-6
lines changed

intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Exercises).ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@
452452
"source": [
453453
"# Grab some data \n",
454454
"dataiter = iter(trainloader)\n",
455-
"images, labels = dataiter.next()\n",
455+
"images, labels = next(dataiter)\n",
456456
"\n",
457457
"# Resize images into a 1D vector, new shape is (batch size, color channels, image pixels) \n",
458458
"images.resize_(64, 1, 784)\n",

intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Solution).ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
],
113113
"source": [
114114
"dataiter = iter(trainloader)\n",
115-
"images, labels = dataiter.next()\n",
115+
"images, labels = next(dataiter)\n",
116116
"print(type(images))\n",
117117
"print(images.shape)\n",
118118
"print(labels.shape)"
@@ -650,7 +650,7 @@
650650
"source": [
651651
"# Grab some data \n",
652652
"dataiter = iter(trainloader)\n",
653-
"images, labels = dataiter.next()\n",
653+
"images, labels = next(dataiter)\n",
654654
"\n",
655655
"# Resize images into a 1D vector, new shape is (batch size, color channels, image pixels) \n",
656656
"images.resize_(64, 1, 784)\n",

intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"# Test out your network!\n",
208208
"\n",
209209
"dataiter = iter(testloader)\n",
210-
"images, labels = dataiter.next()\n",
210+
"images, labels = next(dataiter)\n",
211211
"img = images[1]\n",
212212
"\n",
213213
"# TODO: Calculate the class probabilities (softmax) for img\n",

intro-to-pytorch/Part 5 - Inference and Validation (Exercises).ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
"model.eval()\n",
368368
"\n",
369369
"dataiter = iter(testloader)\n",
370-
"images, labels = dataiter.next()\n",
370+
"images, labels = next(dataiter)\n",
371371
"img = images[0]\n",
372372
"# Convert 2D image to 1D vector\n",
373373
"img = img.view(1, 784)\n",

intro-to-pytorch/Part 5 - Inference and Validation (Solution).ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@
507507
"model.eval()\n",
508508
"\n",
509509
"dataiter = iter(testloader)\n",
510-
"images, labels = dataiter.next()\n",
510+
"images, labels = next(dataiter)\n",
511511
"img = images[0]\n",
512512
"# Convert 2D image to 1D vector\n",
513513
"img = img.view(1, 784)\n",

0 commit comments

Comments
 (0)