Hi I'm new to RBM and machine learning/computer vision in general, and I'm using the code from: http://blog.echen.me/2011/07/18/introduction-to-restricted-boltzmann-machines/ while reading on https://en.wikipedia.org/wiki/Restricted_Boltzmann_machine for some theories. But right now i'm totally confused. In the code there is a part:

# Calculate the activations of the hidden units.
      hidden_activations = np.dot(visible, self.weights)      
      # Calculate the probabilities of turning the hidden units on.
      hidden_probs = self._logistic(hidden_activations)

I assume the equivalence in wikipedia would be the conditional probability, but when I look that up, nothing makes sense! I mean, what are v and h, are they supposed to be vectors or values? (I assume they are in fact just values, as wikipedia only talks about each seperate samples while the code groups all of them into a matrix, but even them it's still hazy :( ). I'm new to this so my question may be a little dumb but please help me. Thank you very much! P/s: Sorry I am unable to post the equations :(


1 Answer 1


The equation from the wikipedia implemented with this code is the one in picture bellow. Sigma function is logistic sigmoid (self._logistic()). The dot product is the sum of products bellow. bj is offset and might be included in the sum (some visible neuron is always 1) or it might be omitted completely for simplicity or something else.

The equivalence

  • $\begingroup$ Thanks for the equation but I still don't know why the code is written the way it is :( $\endgroup$ Commented Nov 9, 2015 at 1:50
  • $\begingroup$ It seems you misunderstood me, the problem here is that I don't understand how the code correlates to the wikipedia equations :( Please help me, I am just a newbie. Thank you very much! $\endgroup$ Commented Nov 9, 2015 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.