5. ComputerVision: Facing an issue on Test_step fucntion by following your videos #739
takvir-imran
started this conversation in
General
Replies: 1 comment
-
Got ya, you need to do any modifications with the variables inside of
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
def test_step(model: torch.nn.Module,
data_loader: torch.utils.data.DataLoader,
loss_fn: torch.nn.Module,
accuracy_fn,
device: torch.device = device):
test_loss, test_acc = 0, 0
model.eval()
with torch.inference_mode():
for X, y in data_loader:
X, y = X.to(device), y.to(device)
Xc=X.clone()
test_pred = model(Xc)
test_loss += loss_fn(test_pred, y)
test_acc += accuracy_fn(y_true=y,
y_pred=test_pred.argmax(dim=1))
test_loss /= len(data_loader)
test_acc /= len(data_loader)
print(f"\n Test Loss: {test_loss:.5f} || Test Accuracy: {test_acc:.4f}\n")
The errror:

@mrdbourke can you help me out. Tried different ways but facing this problem
Beta Was this translation helpful? Give feedback.
All reactions