I have been having a bit of a personal fight with fully understanding the bolzmann machine. It is especially the sampling phases that I cannot wrap my head around, as well as the probability distributions.

So the overall way I have understood it so far is:

  1. Positive phase:

    • clamp sample from input to visible units (units are fixed)
    • sample hidden units until thermal equilibrium is reached
    • weights get updated for two units being active
  2. negative phase:

    • both visible and hidden units are sampled until thermal equilibrium is reached
    • decrease weights for two units being active.

Intuitively this all makes sense, but the sampling which is mentioned several times gives me quite a headache.

First of all, as sampling i guess one can use simulated annealing or gibbs sampling. When we do sample, do we sample from the joint probabiliy distribution p(v,h) in both phases? Or do we only sample from p(h) in the positive phase? Or do we sample out of the input space? Because in case of Gibbs sampling we need to know the $P(X_k|X_{-k})$ But I guess we just compute nodes activation using: $P(X_i|X_j's)$ - so going over the corresponding markov-chain. But again, where is my starting point since some of the nodes in the hiddenphase, basically all the ones but the one that we are getting the activation don't have value yet, so are they just ignored in the first run and included into the chain once their activation has been computed?

Now I also read that for updating the weights, we need to sample of the positive phase as well as the negative phase. But I cannot quite follow why sampling is necessary can't I just some over all the activations and get value? In case of the positive phase: $\sum_{x_{\alpha}}\sum_{x_{\beta}}P(X=x|X=x)x_ix_j$ Because I can just compute the value of P for each of the nodes given the other since that formula is also given. So where and how comes sampling into play here? Or is with sampling in this case just meant that I have to follow the whole markov chain again?

I am pretty sure I struggle with the concept of sampling and haven't fully understood the way the bolzmann machine works yet. I guess my understanding here is rather fuzzy. Every time I feel like I got how it works I loose that feeling right away, in general I struggle organising all the formulas.

In general even looking at the corresponding algorithms a do not really get where and how I obtain my starting point.

So to summarize: - Where do I sample from for each phase? - Why do I need to sample to get the mean firing right for the positive and negative phase respectively - When we do sample, either gibbs or simulated annealing how is my starting point determined.


1 Answer 1


In the positive phase, the gradient is $E[hx^T|x] = E[h|x]x^T$. Since $E[h|x]$ can be computed without sampling, there is no sampling involved in the first phase.

In the negative phase, the gradient is $-E[hx^T]$. We must sample some $h', x'$ from the $\textit{joint}$ distribution and then approximate $-E[hx^T$] as $-h'x'^T$.

The reason we need to sample is because computing this expectation is intractable. The sampling is done by block Gibbs sampling: first we start with the given $x$ which is the datapoint you are training on. Then sample some $h|x$, then sample some $x|h$, and so on. Stop after sampling $k$ times of this.

Edit: For the general (unrestricted) Boltzmann machine, computing $E[h|x]$ requires sampling as well. The easiest way to do this is to fix all the values of the visible $x$, and then sample a new value $h_i' \leftarrow h_i|h_{-i},x$ for some random hidden node $i$. Repeat this until the process converges.

Theoretically, starting the hidden nodes at any value will result in convergence, since the markov chain is stationary. I think in practice, starting from the last hidden state should lead to good behaviour.

From what I know of it, simulated annealing is usually used for optimization, so it could find $\max_h P(h|x)$, which might be a good starting point for the gibbs sampler, but I haven't seen it mentioned as a sampler by its own.

  • $\begingroup$ How can the values in the positive phased be computed without sampling? Since the activation of one hidden unit is also dependent on all the other units but their values are unknown too? $\endgroup$
    – SandraK
    Commented Oct 28, 2017 at 4:06
  • $\begingroup$ The probability of the hidden units are dependent only on the visible units. In fact, $E[h|x] = \sigma(b+Wx)$ $\endgroup$
    – shimao
    Commented Oct 28, 2017 at 4:07
  • $\begingroup$ Yes but that is only the case for the Restricted Bolzman machine. My question is related to the Bolzman machine - thats the one that gives the confusion $\endgroup$
    – SandraK
    Commented Oct 28, 2017 at 4:19
  • $\begingroup$ Ok, I see. I edited the answer $\endgroup$
    – shimao
    Commented Oct 28, 2017 at 4:58

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.