| 425 | |
| 426 | #FUNCTION TO PLOT THE TRAINING |
| 427 | def plot_training(fit): |
| 428 | best_epoch = fit.epoch[fit.history['val_loss'].index(min(fit.history['val_loss']))] |
| 429 | fig, ax = plt.subplots(figsize=(3,3)) |
| 430 | ax.plot(fit.epoch,fit.history['val_loss'],'.-',color='red', label='validation') |
| 431 | ax.plot(fit.epoch,fit.history['loss'],'.-',color='orange', label='train') |
| 432 | ax.set_yscale('log') |
| 433 | ax.set(ylabel='MSE') |
| 434 | ax.axvspan(best_epoch-0.5,best_epoch+0.5, alpha=0.5, color='red') |
| 435 | ax.legend() |
| 436 | print("[Best epoch]:", best_epoch) |
| 437 | print("[MSE]:", min(fit.history['val_loss'])) |
| 438 | |
| 439 | |
| 440 | |