Using neural networks to learn intractable generative models