two layer inference (lagrangian)