A new inference approach for training shallow and deep generalized linear models of noisy interacting neurons