Hi,
No. You don’t have to call loss.backward() during validation since the purpose of validation is to assess the model on “unseen” data during training (although validation data does not remain unseen when you use do validation over different folds; You can ignore this to avoid confusion and subtleties to it can be discussed later).
loss.backward() is called to compute gradient of loss w.r.t to each trainable parameter. Now since during validation you don’t want to update model based on validation loss (because that would kill the purpose of validation, that is, to test the model on a portion (say 10%) of training data after training it on the other portion (i.e. 90%).
Side note: “with torch.no_grad()” is just to do assessment without involving gradients (or keeping track of gradients) because you anyway don’t want to deal with gradients or any kind of update to trainable parameters, during the assessment (i.e. validation).