Equilibrium and non-Equilibrium regimes in the learning of Restricted Boltzmann Machines