Implementation of the Helmholtz machine as described in "Hinton, Dayan, Frey, Neal, The Wake-Sleep Algorithm for Unsupervised Neural Networks, Science, 1996" Figure 2