Numerical estimation of information measures and learning generative models