Skip to content
Discussion options

You must be logged in to vote

Hi @Aditi4AI ,

I think Python is getting confused between your variables Loss and loss.

You could try rewriting your function to set loss as loss_fn and Loss as test_loss to escape the confusion.

Also in the line:

model_0_results=eval_model(model=model_0,data_loader=test_dataloader,loss:Loss,accuracy=acc)

You have written loss:Loss, this should be loss=Loss.

But I have updated the whole code to reflect the updates:

#next (model_0.parameters())
#torch.manual_seed(53)
def eval_model(model:torch.nn.Module, data_loader:torch.utils.data.DataLoader, loss_fn: torch.nn.Module, accuracy):
    test_loss, acc = 0, 0
    model.eval()
    with torch.inference_mode():
        for x, y in data_loader:
…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Aditi4AI
Comment options

@mrdbourke
Comment options

Answer selected by mrdbourke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants