Skip to content

Why x_test is run using inference_model, and not undergo the usual process such backpop, optimizer and so on? #215

Answered by sashanktalakola
ammarsaf asked this question in Q&A
Discussion options

You must be logged in to vote

When a model is initialized random weights will be assigned, based of those particular weights it will make a prediction on X_test. Since, its not trained it will output some incorrect value.

Validation and Testing should be done in inference mode because here we will not be worrying about the gradients. During training gradients need to be computed torch does it with the help of autograd, but during testing there is need for it so we perform in inference mode. Since, we dont train in test data there will not be steps such as optimizer.zero_grad( ), loss.backward( ) , optim.step( ) .

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ammarsaf
Comment options

Answer selected by ammarsaf
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