Skip to content

Commit

Permalink
Refactor FashionMNIST notebook to use next() for data iterator and …
Browse files Browse the repository at this point in the history
…fix subplot division (#3322)
  • Loading branch information
k22036 authored Jan 4, 2025
1 parent ac89ed3 commit 23f2a3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/notebooks/FashionMNIST.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
"classes = ['T-shirt/top','Trouser','Pullover','Dress','Coat','Sandal','Shirt','Sneaker','Bag','Ankle Boot']\n",
"# creating iterator for iterating the dataset\n",
"dataiter = iter(val_loader)\n",
"images, labels = dataiter.next()\n",
"images, labels = next(dataiter)\n",
"images_arr = []\n",
"labels_arr = []\n",
"pred_arr = []\n",
Expand All @@ -621,7 +621,7 @@
"# plotting the results\n",
"fig = plt.figure(figsize=(25,4))\n",
"for i in range(10):\n",
" ax = fig.add_subplot(2, 20/2, i+1, xticks=[], yticks=[])\n",
" ax = fig.add_subplot(2, 20//2, i+1, xticks=[], yticks=[])\n",
" ax.imshow(images_arr[i].resize_(1, 28, 28).numpy().squeeze())\n",
" ax.set_title(\"{} ({})\".format(classes[pred_arr[i]], classes[labels_arr[i]]),\n",
" color=(\"green\" if pred_arr[i]==labels_arr[i] else \"red\"))"
Expand Down

0 comments on commit 23f2a3f

Please sign in to comment.