Skip to content

Commit

Permalink
Avoid setting test_iter.epoch manually (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
toslunar committed Mar 7, 2020
1 parent 8536845 commit 7e8a134
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Expand Up @@ -583,7 +583,7 @@
"\n",
" test_losses = []\n",
" test_accuracies = []\n",
" while True:\n",
" for test_batch in test_iter:\n",
" test_batch = test_iter.next()\n",
" image_test, target_test = concat_examples(test_batch, gpu_id)\n",
"\n",
Expand All @@ -598,13 +598,8 @@
" accuracy = F.accuracy(prediction_test, target_test)\n",
" accuracy.to_cpu()\n",
" test_accuracies.append(accuracy.data)\n",
" \n",
" if test_iter.is_new_epoch:\n",
" test_iter.epoch = 0\n",
" test_iter.current_position = 0\n",
" test_iter.is_new_epoch = False\n",
" test_iter._pushed_position = None\n",
" break\n",
"\n",
" test_iter.reset()\n",
"\n",
" print('val_loss:{:.04f} val_accuracy:{:.04f}'.format(\n",
" np.mean(test_losses), np.mean(test_accuracies)))"
Expand Down
Expand Up @@ -547,7 +547,7 @@
"\n",
" test_losses = []\n",
" test_accuracies = []\n",
" while True:\n",
" for test_batch in test_iter:\n",
" test_batch = test_iter.next()\n",
" x_test, t_test = concat_examples(test_batch, gpu_id)\n",
"\n",
Expand All @@ -562,13 +562,8 @@
" accuracy = F.accuracy(y_test, t_test)\n",
" accuracy.to_cpu()\n",
" test_accuracies.append(accuracy.data)\n",
" \n",
" if test_iter.is_new_epoch:\n",
" test_iter.epoch = 0\n",
" test_iter.current_position = 0\n",
" test_iter.is_new_epoch = False\n",
" test_iter._pushed_position = None\n",
" break\n",
"\n",
" test_iter.reset()\n",
"\n",
" print('val_loss:{:.04f} val_accuracy:{:.04f}'.format(\n",
" np.mean(test_losses), np.mean(test_accuracies)))"
Expand Down

0 comments on commit 7e8a134

Please sign in to comment.