Plotting train/validation loss & accuracy while training model?

(rohit) #1

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

(Vishal Pandey) #2

There is a github repo I have come across VisualDL.

(Michael) #3

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

(Al A Latif) #4

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

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

(Karl) #6

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')``````