Skip to content

Commit 588a8c6

Browse files
author
Alvaro Bartolome
committed
fixed error while training model (running acc/loss)
1 parent 6a36deb commit 588a8c6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

notebooks/transfer-learning.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,11 @@
715715
"EPOCHS = 15\n",
716716
"\n",
717717
"for epoch in range(1, EPOCHS+1):\n",
718-
" running_loss = .0\n",
719-
" running_corrects = .0\n",
720718
" best_acc = .0\n",
721719
" print(f\"\\nEpoch {epoch}/{EPOCHS}\\n{'='*25}\")\n",
722720
" for phase in ['train', 'val']:\n",
721+
" running_loss = .0\n",
722+
" running_corrects = .0\n",
723723
" if phase == 'train': model.train()\n",
724724
" if phase == 'val': model.eval()\n",
725725
" for inputs, labels in loaders[phase]:\n",
@@ -742,7 +742,7 @@
742742
" epoch_acc = running_corrects.double() / dataset_sizes[phase]\n",
743743
" if phase == 'train': scheduler.step()\n",
744744
" if phase == 'val' and epoch_acc > best_acc:\n",
745-
" best_corrects = epoch_acc\n",
745+
" best_acc = epoch_acc\n",
746746
" best_model_weights = deepcopy(model.state_dict())\n",
747747
" print(f\"Loss ({phase}): {epoch_loss}, Acc ({phase}): {epoch_acc}\")"
748748
]

0 commit comments

Comments
 (0)