Like @ptrblck have said, calculate loss and accuracy on train and val set for each epoch and save these stats using lists and write it to a json or yaml file. After training process finishes, using matplotlib to plot the statistics.