Runtimeerror in train loop. #910
-
This is my train loop:-
What should I do to handle this error.
|
Beta Was this translation helpful? Give feedback.
Answered by
sametucuncu
May 10, 2024
Replies: 1 comment
-
The loss is the error between expected output of the model (Y_train) and model's prediction which is y_pred in your case (y_pred = model1(X_train)). y_pred_act = torch.argmax(torch.sigmoid(y_pred), dim = 1).float() is calculating the label from predicted value of the model. It is not exact output of the model. So, you should use output of the model while calculating the loss. So loss should be: loss = loss_fn(y_pred, Y_train) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
GAuravY19
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The loss is the error between expected output of the model (Y_train) and model's prediction which is y_pred in your case (y_pred = model1(X_train)).
y_pred_act = torch.argmax(torch.sigmoid(y_pred), dim = 1).float() is calculating the label from predicted value of the model. It is not exact output of the model. So, you should use output of the model while calculating the loss. So loss should be:
loss = loss_fn(y_pred, Y_train)