You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I have a Problem in getting model results. The training part works just fine. But the evaluation part confuses the hell out of me.
Here is the Code I'm talking about:
torch.manual_seed(42)
def eval_model(model: torch.nn.Module, data_loader: torch.utils.data.DataLoader, loss_fn: torch.nn.Module,accuracy_fn):
loss, acc = 0,0
model.eval()
with torch.inference_mode():
for X,y in data_loader:
y_pred = model(X)
/tmp/ipykernel_33231/3664206720.py in eval_model(model, data_loader, loss_fn, accuracy_fn)
4 model.eval()
5 with torch.inference_mode():
----> 6 for X,y in data_loader:
7 y_pred = model(X)
8 ...
...
TypeError: ToTensor.init() takes 1 positional argument but 2 were given
I even copied the code from gitlab to resolve the issue because I was so desparate. Pls help me Daniel :D Or anybody else.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I have a Problem in getting model results. The training part works just fine. But the evaluation part confuses the hell out of me.
Here is the Code I'm talking about:
torch.manual_seed(42)
def eval_model(model: torch.nn.Module, data_loader: torch.utils.data.DataLoader, loss_fn: torch.nn.Module,accuracy_fn):
loss, acc = 0,0
model.eval()
with torch.inference_mode():
for X,y in data_loader:
y_pred = model(X)
model_0_results = eval_model(model=model_0, data_loader = test_dataloader, loss_fn=loss_fn,accuracy_fn = accuracy_fn)
And here is the Error:
TypeError Traceback (most recent call last)
/tmp/ipykernel_33231/1605480602.py in
----> 1 model_0_results = eval_model(model=model_0, data_loader = test_dataloader, loss_fn=loss_fn,accuracy_fn = accuracy_fn)
/tmp/ipykernel_33231/3664206720.py in eval_model(model, data_loader, loss_fn, accuracy_fn)
4 model.eval()
5 with torch.inference_mode():
----> 6 for X,y in data_loader:
7 y_pred = model(X)
8 ...
...
TypeError: ToTensor.init() takes 1 positional argument but 2 were given
I even copied the code from gitlab to resolve the issue because I was so desparate. Pls help me Daniel :D Or anybody else.
Beta Was this translation helpful? Give feedback.
All reactions