mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
Merge pull request #369 from svarunid/main
make sure model on target device
This commit is contained in:
1 file changed
+2
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user