Debugged and working for bernoulli rbm