Plotting train/validation loss & accuracy while training model?

Hi,
When using the Pytorch-based fastai library, is it possible to plot the training and validation losses and accuracy while the model is being trained? e.g., this would be similar to the live graphs in tensorboard that plot the training, validation loss and accuracy. I’ve found it very helpful to view the graphs during long running model training.

Thanks,
Rohit

3 Likes

There is a github repo I have come across VisualDL.

Hello,

is there an simple way to just have another curve for the validation loss with ‘learn.sched.plot_loss()’ to show train & val loss simultanously?

Or maybe even the metrics next to both losses?

I couldn’t find anything in the forums and the fastai source code.

Best regards
Michael

1 Like

Same here! Still looking for a way to create these plots. Will make sure to post here if I figure it out :slight_smile:

I posted a way to do this in another thread you can find herehttp://forums.fast.ai/t/how-do-i-access-training-loss-when-running-learn-fit/17821

1 Like

This notebook shows plotting of train/val loss and accuracy after running learn.fit.

fig,ax = plt.subplots(2,1,figsize=(8,12))
ax[0].plot(list(range(95)),learn.sched.val_losses, label='Validation loss')
ax[0].plot(list(range(95)),[learn.sched.losses[i] for i in range(97,95*98,98)], label='Training 
loss')
ax[0].set_xlabel('Epoch')
ax[0].set_ylabel('Loss')
ax[0].legend(loc='upper right')
ax[1].plot(list(range(95)),learn.sched.rec_metrics)
ax[1].set_xlabel('Epoch')
ax[1].set_ylabel('Accuracy')
3 Likes

No one has posted fastAI’s dynamic ShowGraph callback function so far. I have been using it for the purpose of observing losses during training.
See: https://docs.fast.ai/train.html#ShowGraph

I have not plotted my accuracy during training, but you can certainly do that with callbacks. You may have to write your own.

3 Likes