|
118 | 118 | "criterion = nn.CrossEntropyLoss()\n", |
119 | 119 | "\n", |
120 | 120 | "# Get our data\n", |
121 | | - "images, labels = next(iter(trainloader))\n", |
| 121 | + "dataiter = iter(trainloader)\n", |
| 122 | + "\n", |
| 123 | + "images, labels = next(dataiter)\n", |
| 124 | + "\n", |
122 | 125 | "# Flatten images\n", |
123 | 126 | "images = images.view(images.shape[0], -1)\n", |
124 | 127 | "\n", |
|
153 | 156 | "\n", |
154 | 157 | "### Run this to check your work\n", |
155 | 158 | "# Get our data\n", |
156 | | - "images, labels = next(iter(trainloader))\n", |
| 159 | + "dataiter = iter(trainloader)\n", |
| 160 | + "\n", |
| 161 | + "images, labels = next(dataiter)\n", |
| 162 | + "\n", |
157 | 163 | "# Flatten images\n", |
158 | 164 | "images = images.view(images.shape[0], -1)\n", |
159 | 165 | "\n", |
|
310 | 316 | " nn.LogSoftmax(dim=1))\n", |
311 | 317 | "\n", |
312 | 318 | "criterion = nn.NLLLoss()\n", |
313 | | - "images, labels = next(iter(trainloader))\n", |
| 319 | + "dataiter = iter(trainloader)\n", |
| 320 | + "images, labels = next(dataiter)\n", |
314 | 321 | "images = images.view(images.shape[0], -1)\n", |
315 | 322 | "\n", |
316 | 323 | "logits = model(images)\n", |
|
373 | 380 | "source": [ |
374 | 381 | "print('Initial weights - ', model[0].weight)\n", |
375 | 382 | "\n", |
376 | | - "images, labels = next(iter(trainloader))\n", |
| 383 | + "dataiter = iter(trainloader)\n", |
| 384 | + "images, labels = next(dataiter)\n", |
377 | 385 | "images.resize_(64, 784)\n", |
378 | 386 | "\n", |
379 | 387 | "# Clear the gradients, do this because gradients are accumulated\n", |
|
458 | 466 | "%matplotlib inline\n", |
459 | 467 | "import helper\n", |
460 | 468 | "\n", |
461 | | - "images, labels = next(iter(trainloader))\n", |
| 469 | + "dataiter = iter(trainloader)\n", |
| 470 | + "images, labels = next(dataiter)\n", |
462 | 471 | "\n", |
463 | 472 | "img = images[0].view(1, 784)\n", |
464 | 473 | "# Turn off gradients to speed up this part\n", |
|
494 | 503 | "name": "python", |
495 | 504 | "nbconvert_exporter": "python", |
496 | 505 | "pygments_lexer": "ipython3", |
497 | | - "version": "3.6.7" |
| 506 | + "version": "3.8.5" |
498 | 507 | } |
499 | 508 | }, |
500 | 509 | "nbformat": 4, |
|
0 commit comments