Merge pull request #369 from svarunid/main

make sure model on target device
This commit is contained in:
Daniel Bourke authored and GitHub committed 2023-04-13 12:10:39 +10:00
commit 372b33b140
1 file changed
+2
+2
View File
@@ -1497,6 +1497,7 @@
" accuracy_fn,\n",
" device: torch.device = device):\n",
" train_loss, train_acc = 0, 0\n",
" model.to(device)\n",
" for batch, (X, y) in enumerate(data_loader):\n",
" # Send data to GPU\n",
" X, y = X.to(device), y.to(device)\n",
@@ -1530,6 +1531,7 @@
" accuracy_fn,\n",
" device: torch.device = device):\n",
" test_loss, test_acc = 0, 0\n",
" model.to(device)\n",
" model.eval() # put model in eval mode\n",
" # Turn on inference context manager\n",
" with torch.inference_mode(): \n",