Dynamical learning of a photonics quantum-state engineering process