What is the use of torch.no_grad()?

Use of @torch.no_grad()

It’s a decorator which will apply no_grad function of pytorch everytime,when you will call evaluate function for validation set.

1 Like

It tells PyTorch not to track gradients when the decorated function is being executed.