Setup
- Use the
torch.no_grad()
method to turn off gradients for validation, as it saves memory and computations.
Evaluation / Test Loop
topk()
method gives the 𝑘 highest values. This returns a tuple of the top-𝑘 values and the top-𝑘 indices. If the highest value is the fifth element, we'll get back 4 as the index. When we want to know the most likely class in a prediction, we can use ps.topk(1)
, being that ps
is a tensor containing output probabilities. Learn more about this method here: https://pytorch.org/docs/stable/torch.html#torch.topk
Tensorboard on PyTorch