From 78e38737b8d10ccdc7fcd3cbff26ce0bbce093d5 Mon Sep 17 00:00:00 2001 From: Vadim Pushtaev Date: Tue, 28 Feb 2023 23:27:11 +0200 Subject: [PATCH 1/2] intro to pytorch: Part 2, next() is not a method --- .../Part 2 - Neural Networks in PyTorch (Exercises).ipynb | 2 +- .../Part 2 - Neural Networks in PyTorch (Solution).ipynb | 4 ++-- intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb | 2 +- .../Part 5 - Inference and Validation (Exercises).ipynb | 2 +- .../Part 5 - Inference and Validation (Solution).ipynb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Exercises).ipynb b/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Exercises).ipynb index b6591c9c21..a507ec4560 100644 --- a/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Exercises).ipynb +++ b/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Exercises).ipynb @@ -452,7 +452,7 @@ "source": [ "# Grab some data \n", "dataiter = iter(trainloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "\n", "# Resize images into a 1D vector, new shape is (batch size, color channels, image pixels) \n", "images.resize_(64, 1, 784)\n", diff --git a/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Solution).ipynb b/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Solution).ipynb index 77ba591ad1..0b0bbba1e0 100644 --- a/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Solution).ipynb +++ b/intro-to-pytorch/Part 2 - Neural Networks in PyTorch (Solution).ipynb @@ -112,7 +112,7 @@ ], "source": [ "dataiter = iter(trainloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "print(type(images))\n", "print(images.shape)\n", "print(labels.shape)" @@ -650,7 +650,7 @@ "source": [ "# Grab some data \n", "dataiter = iter(trainloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "\n", "# Resize images into a 1D vector, new shape is (batch size, color channels, image pixels) \n", "images.resize_(64, 1, 784)\n", diff --git a/intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb b/intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb index ad60cbf16c..69bc607552 100644 --- a/intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb +++ b/intro-to-pytorch/Part 4 - Fashion-MNIST (Solution).ipynb @@ -207,7 +207,7 @@ "# Test out your network!\n", "\n", "dataiter = iter(testloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "img = images[1]\n", "\n", "# TODO: Calculate the class probabilities (softmax) for img\n", diff --git a/intro-to-pytorch/Part 5 - Inference and Validation (Exercises).ipynb b/intro-to-pytorch/Part 5 - Inference and Validation (Exercises).ipynb index 989eaee9aa..7225aedba7 100644 --- a/intro-to-pytorch/Part 5 - Inference and Validation (Exercises).ipynb +++ b/intro-to-pytorch/Part 5 - Inference and Validation (Exercises).ipynb @@ -367,7 +367,7 @@ "model.eval()\n", "\n", "dataiter = iter(testloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "img = images[0]\n", "# Convert 2D image to 1D vector\n", "img = img.view(1, 784)\n", diff --git a/intro-to-pytorch/Part 5 - Inference and Validation (Solution).ipynb b/intro-to-pytorch/Part 5 - Inference and Validation (Solution).ipynb index 33275ecc37..9fcaea85b1 100644 --- a/intro-to-pytorch/Part 5 - Inference and Validation (Solution).ipynb +++ b/intro-to-pytorch/Part 5 - Inference and Validation (Solution).ipynb @@ -507,7 +507,7 @@ "model.eval()\n", "\n", "dataiter = iter(testloader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "img = images[0]\n", "# Convert 2D image to 1D vector\n", "img = img.view(1, 784)\n", From bdee1b888df2caf03b0e42ec1da01869b63acf7f Mon Sep 17 00:00:00 2001 From: Vadim Pushtaev Date: Sun, 9 Apr 2023 23:19:40 +0300 Subject: [PATCH 2/2] convo nn: next() is not a method --- .../mnist-mlp/mnist_mlp_exercise.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convolutional-neural-networks/mnist-mlp/mnist_mlp_exercise.ipynb b/convolutional-neural-networks/mnist-mlp/mnist_mlp_exercise.ipynb index 412f3bf47a..8896eac06f 100644 --- a/convolutional-neural-networks/mnist-mlp/mnist_mlp_exercise.ipynb +++ b/convolutional-neural-networks/mnist-mlp/mnist_mlp_exercise.ipynb @@ -108,7 +108,7 @@ " \n", "# obtain one batch of training images\n", "dataiter = iter(train_loader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "images = images.numpy()\n", "\n", "# plot the images in the batch, along with the corresponding labels\n", @@ -360,7 +360,7 @@ "source": [ "# obtain one batch of test images\n", "dataiter = iter(test_loader)\n", - "images, labels = dataiter.next()\n", + "images, labels = next(dataiter)\n", "\n", "# get sample outputs\n", "output = model(images)\n",