mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
make sure model on traget device
In section 6.2 while defining train_step and test_step functions move also the model to target device.
This commit is contained in:
1 parent
6db24449d9
commit
7951c262fd
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