def plot_train_val(patterns, fontsize=15): import matplotlib.pyplot as plt import seaborn as sns import matplotlib.ticker as ticker dummy_trainer = Train(None, None, None, None) for pattern in patterns: for cpt_fn in glob.glob(pattern): cpt = torch.load(cpt_fn) name = cpt_fn.split('.')[0].split('/')[-1] l = cpt['train_losses'] dummy_trainer.all_losses = l plt.plot(dummy_trainer.smooth_loss(), label=name) plt.legend(loc='center right', bbox_to_anchor=(1.5, 0.5)) plt.title('training loss (RMSE)', fontsize=fontsize) plt.grid() plt.show() for pattern in patterns: for cpt_fn in glob.glob(pattern): cpt = torch.load(cpt_fn) name = cpt_fn.split('.')[0].split('/')[-1] l = cpt['val_losses'] dummy_trainer.val_losses = l plt.plot(dummy_trainer.smooth_valloss(), label=name) plt.legend(loc='center right', bbox_to_anchor=(1.5, 0.5)) plt.title('validation loss (RMSE)', fontsize=fontsize) plt.grid() plt.show()
def get_train_val_curves(pattern): dummy_trainer = Train(None, None, None, None) tr_curves = [] val_curves = [] name = "" for cpt_fn in glob.glob(pattern): cpt = torch.load(cpt_fn) name = cpt_fn.split('.')[0].split('/')[-1] dummy_trainer.all_losses = cpt['train_losses'] dummy_trainer.val_losses = cpt['val_losses'] tr_curves.append(dummy_trainer.smooth_loss()) val_curves.append(dummy_trainer.smooth_valloss()) return tr_curves, val_curves, name