Skip to content

Commit 52089d2

Browse files
committed
fix iter next
1 parent cf2b6be commit 52089d2

File tree

2 files changed

+246
-258
lines changed

2 files changed

+246
-258
lines changed

c_10_neural_networks_basics/fully_connected.ipynb

+8-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"import matplotlib.pyplot as plt\n",
2424
"\n",
2525
"import torch.nn as nn\n",
26-
"import torch.optim as optim\n"
26+
"import torch.optim as optim\n",
27+
"\n",
28+
"torch.manual_seed(0)"
2729
]
2830
},
2931
{
@@ -669,8 +671,7 @@
669671
}
670672
],
671673
"source": [
672-
"dataiter = iter(test_loader)\n",
673-
"images, labels = dataiter.next()\n",
674+
"images, labels = next(iter(test_loader))\n",
674675
"\n",
675676
"outputs = model(images.to(device))\n",
676677
"\n",
@@ -679,12 +680,12 @@
679680
"figure = plt.figure()\n",
680681
"num_of_images = 20\n",
681682
"for index in range(num_of_images):\n",
682-
" plt.subplot(4, 5, index+1)\n",
683-
" plt.axis('off')\n",
684-
" plt.imshow(images[index,0,:,:], cmap='gray')\n",
683+
" plt.subplot(4, 5, index + 1)\n",
684+
" plt.axis(\"off\")\n",
685+
" plt.imshow(images[index, 0, :, :], cmap=\"gray\")\n",
685686
" prd = int(predicted[index])\n",
686687
" gt = int(labels[index])\n",
687-
" plt.title(f\"pred:{prd}\\n gt:{gt}\" +\"\\nwrong!\"*(prd!=gt))\n",
688+
" plt.title(f\"pred:{prd}\\n gt:{gt}\" + \"\\nwrong!\" * (prd != gt))\n",
688689
"plt.tight_layout()"
689690
]
690691
}

c_11_neural_networks_2/conv_nn.ipynb

+238-251
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)