A Primal-Dual Formulation for Deep Learning with Constraints