Per-class and per-sample weighting

You shouldn’t be running the loss function on the test set. The test set should always be for evaluation only—never training.

Thanks, so I can keep it as:
test_loss += loss_fn(pred, y).item()
In the testing section?

Sorry, I made an assumption about code that you didn’t mention. Calculating the loss would be the same on the training/validation/testing sets.

(However, just make sure that you aren’t computing gradients and updating the weights during the testing set evaluation).