It is well known that conservative mechanical systems exhibit local oscillatory behaviors due to their elastic and gravitational potentials, which completely characterize these periodic motions together with the inertial properties of the system. The classification of these periodic behaviors and their geometric characterization are in an ongoing secular debate, which recently led to the so-called eigenmanifold theory. The eigenmanifold characterizes nonlinear oscillations as a generalization of linear eigenspaces. With the motivation of performing periodic tasks efficiently, we use tools coming from this theory to construct an optimization problem aimed at inducing desired closed-loop oscillations through a state feedback law. We solve the constructed optimization problem via gradient-descent methods involving neural networks. Extensive simulations show the validity of the approach.