Machine learning in and out of equilibrium