From 7951c262fd7853216a60229ed45c5ec17a7ec1bf Mon Sep 17 00:00:00 2001 From: Arun S V Date: Sat, 25 Mar 2023 15:47:29 +0530 Subject: [PATCH] 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. --- 03_pytorch_computer_vision.ipynb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/03_pytorch_computer_vision.ipynb b/03_pytorch_computer_vision.ipynb index ff4bc7a..18892aa 100644 --- a/03_pytorch_computer_vision.ipynb +++ b/03_pytorch_computer_vision.ipynb @@ -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",