103. def eval_model function for evaluating model #840
Replies: 1 comment 7 replies
-
RuntimeError: The size of tensor a (16) must match the size of tensor b (32) at non-singleton dimension 0 From this error |
Beta Was this translation helpful? Give feedback.
7 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.
-
Getting problem at accuracy
`
acc += accuracy_fn(y_true=y, y_pred = y_pred.argmax(dim=1))
model_0_results = eval_model(model=model_0,
data_loader=test_dataloader,
loss_fn=loss_fn,
accuracy_fn=accuracy_fn)
model_0_results`
error: 78.45
107 """
--> 108 correct = torch.eq(y_true, y_pred).sum().item()
109 acc = (correct / len(y_pred)) * 100
110 return acc
RuntimeError: The size of tensor a (16) must match the size of tensor b (32) at non-singleton dimension 0
##Last 3 batch sizes
X shape: torch.Size([32, 1, 28, 28]) | y shape: torch.Size([32]) | y_pred shape: torch.Size([32])
X shape: torch.Size([32, 1, 28, 28]) | y shape: torch.Size([32]) | y_pred shape: torch.Size([32])
X shape: torch.Size([16, 1, 28, 28]) | y shape: torch.Size([16]) | y_pred shape: torch.Size([16])
is last one causes the issue???
Beta Was this translation helpful? Give feedback.
All reactions