Cascade of phase transitions in the training of Energy-based models