Skip to content

Commit 5a87481

Browse files
authored
Modernize cifar10_tutorial
Use `next(iter)` rather than `iter.next()`, which is more Python-3 friendly
1 parent 5f0c061 commit 5a87481

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

beginner_source/blitz/cifar10_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def imshow(img):
105105

106106
# get some random training images
107107
dataiter = iter(trainloader)
108-
images, labels = dataiter.next()
108+
images, labels = next(dataiter)
109109

110110
# show images
111111
imshow(torchvision.utils.make_grid(images))
@@ -210,7 +210,7 @@ def forward(self, x):
210210
# Okay, first step. Let us display an image from the test set to get familiar.
211211

212212
dataiter = iter(testloader)
213-
images, labels = dataiter.next()
213+
images, labels = next(dataiter)
214214

215215
# print images
216216
imshow(torchvision.utils.make_grid(images))

0 commit comments

Comments
 (0)