diff --git a/09_dataloader.py b/09_dataloader.py index 18c76e01..88247da9 100644 --- a/09_dataloader.py +++ b/09_dataloader.py @@ -66,7 +66,7 @@ def __len__(self): # convert to an iterator and look at one random sample dataiter = iter(train_loader) -data = dataiter.next() +data = next(dataiter) features, labels = data print(features, labels) @@ -97,6 +97,6 @@ def __len__(self): # look at one random sample dataiter = iter(train_loader) -data = dataiter.next() +data = next(dataiter) inputs, targets = data print(inputs.shape, targets.shape) diff --git a/13_feedforward.py b/13_feedforward.py index b38f9eb7..29507b28 100644 --- a/13_feedforward.py +++ b/13_feedforward.py @@ -35,7 +35,7 @@ shuffle=False) examples = iter(test_loader) -example_data, example_targets = examples.next() +example_data, example_targets = next(examples) for i in range(6): plt.subplot(2,3,i+1) diff --git a/14_cnn.py b/14_cnn.py index ca0b4cbf..a4abbd1a 100644 --- a/14_cnn.py +++ b/14_cnn.py @@ -45,7 +45,7 @@ def imshow(img): # get some random training images dataiter = iter(train_loader) -images, labels = dataiter.next() +images, labels = next(dataiter) # show images imshow(torchvision.utils.make_grid(images)) diff --git a/16_tensorboard.py b/16_tensorboard.py index 0bd67dc6..21baa49b 100644 --- a/16_tensorboard.py +++ b/16_tensorboard.py @@ -43,7 +43,7 @@ shuffle=False) examples = iter(test_loader) -example_data, example_targets = examples.next() +example_data, example_targets = next(examples) for i in range(6): plt.subplot(2,3,i+1)