I saw many source code about image classification and I found that most people only visualize classification loss during training and only visualize accuracy during test phase.
why is this? how do I know when to stop training?
Hi,
To be honest, Its up to you. You can print and visualize whatever you want during training/validation. You just need to add accuracy calculation after each epoch and visualize it with something like visdom or simply in a terminal.
E.g.,
for x, y_true in validation_loader:
...
y_pred = output.data.max(1)[1] # output is a result of your model
total_loss += loss.item()
num_correct += y_pred.eq(y_true).long().sum().item()
average_loss = total_loss / len(validation_loader)
accuracy = num_correct / len(validation_loader.dataset) * 100
But you never know when you should stop training. There are different recommendations or regularization techniques (e.g., Early stopping), but there is no global solution. So, experiment your way
1 Like