Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.A network that dreams up likely states
A Boltzmann machine is like a Hopfield network whose neurons are a little random. Instead of always switching to whatever their inputs say, they switch on with a probability that rises with the input. Run it for a while and it wanders through states, visiting each in proportion to how “comfortable” (low-energy) it is. Training adjusts the connections so that the states it visits look like the training data. Hidden units, which are never shown data, let it capture patterns that involve many units at once.
Boltzmann machines are the ancestors of energy-based and generative models; Geoffrey Hinton shared the 2024 Nobel Prize in Physics partly for them. Their difficulties (sampling that mixes slowly, intractable normalisation) explain why later generative models use restricted architectures, contrastive divergence, variational methods or diffusion.
- 1. Boltzmann machine units switch on…
- 2. Low-energy states are visited…
- 3. Hidden units let the model capture…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Energy: E(s) = −½sᵀWs − bᵀs for binary s, symmetric W, zero diagonal. Example: s = (1, 1), W = [[0, 2], [2, 0]], b = (0.5, −1): E = −2 + 0.5 = −1.5.
- Distribution: p(s) = exp(−E(s)/T)/Z. Energies 0 and log 3 at T = 1 give probabilities 0.75 and 0.25.
- Gibbs update: p(sᵢ = 1 | rest) = σ((Σⱼ Wᵢⱼsⱼ + bᵢ)/T). With input 2 at T = 1: σ(2) ≈ 0.881.
- Learning rule: ∂log p(data)/∂Wᵢⱼ = ⟨sᵢsⱼ⟩_data − ⟨sᵢsⱼ⟩_model. The first average has visible units clamped to data and hidden units sampled; the second runs the network freely. Example: 0.7 − 0.4 = 0.3.
- Cost: n units have 2ⁿ states (1024 for 10, 2¹⁰⁰ for 100), so Z and the model average must be estimated by sampling.
- 1. Probabilities for energies 0 and log 3:
- 2. Weight gradient for data correlation 0.7, model 0.4:
- 3. States of 10 binary units:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Boltzmann machines in code
Exercise 1. A 4-unit machine with random weights was Gibbs-sampled for 40 000 sweeps; the sampled frequencies of the 16 states matched the exact probabilities to within 0.002, with KL below 10⁻³.
Practice.
- General Boltzmann machines are rarely trained today: the free-running statistics need long Gibbs chains that mix slowly when weights are large (see the demo).
- Restricting the connectivity (no visible–visible or hidden–hidden links) gives the RBM (E6-9), whose conditionals factorise and which trains with contrastive divergence.
- Persistent chains, parallel tempering and annealed importance sampling are the standard tools for sampling and estimating Z.
for i in range(n): # one Gibbs sweep
s[i] = rng.uniform() < 1 / (1 + np.exp(-(W[i] @ s + b[i])))- 1. Gibbs chains mix slowly when…
- 2. Restricting connectivity gives…
- 3. Parallel tempering helps by…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
The learning rule. log p(v) = log Σₕ exp(−E(v, h)) − log Z. Differentiating, ∂/∂Wᵢⱼ gives ⟨sᵢsⱼ⟩ under p(h | v), minus ⟨sᵢsⱼ⟩ under p(v, h). Averaged over data, this is the difference between clamped (“wake”) and free (“sleep”) correlations: Hebbian learning on data and anti-Hebbian unlearning on the model’s own fantasies.
Maximum entropy. A visible-only Boltzmann machine is the maximum-entropy distribution matching the data’s means and pairwise correlations. If the data’s structure lies in higher-order correlations, as in parity, whose pairwise statistics are those of the uniform distribution, no visible-only machine can do better than uniform.
Hidden units. Marginalising hidden units yields effective higher-order interactions among visibles. With enough hidden units, Boltzmann machines (even RBMs) can approximate any distribution over binary vectors (Le Roux and Bengio, 2008).
Intractability. Both Z and the free-phase statistics are sums over exponentially many states; sampling them by Gibbs chains is slow when the distribution has well-separated modes. This drove the move to RBMs and contrastive divergence.
- 1. The free-phase correlations act as…
- 2. A visible-only BM is the max-entropy model matching…
- 3. Even parity's pairwise statistics equal those of…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Why hidden units matter
History.
- D. Ackley, G. Hinton and T. Sejnowski (1985) introduced Boltzmann machines and their learning rule.
- P. Smolensky (1986) introduced the harmonium (the RBM).
- R. Salakhutdinov and G. Hinton (2009) trained deep Boltzmann machines.
- G. Hinton shared the 2024 Nobel Prize in Physics with J. Hopfield.
Exercise 2. Data: the four 3-bit strings with even parity, each with probability ¼. Boltzmann machines with 3 visible units and 0–3 hidden units, trained by exact gradient ascent (all states enumerated, 4000 steps, three seeds):
| hidden units | KL(data ‖ model) |
|---|---|
| 0 | 0.6931 (= log 2) |
| 1 | 0.1205 |
| 2 | 0.1022 |
| 3 | 0.0469 |
- Without hidden units the machine learned exactly the uniform distribution (KL = log 2), because parity’s means and pairwise correlations are the uniform distribution’s.
- Hidden units captured the third-order structure; three cut the KL to 0.05 within the training budget.
- Note: from very small initial weights (scale 0.1) every machine stayed at log 2: the parity gradient vanishes at that symmetric starting point, and weights of scale 1 were needed to break the symmetry.
Boltzmann machines in AI, robotics and aerospace
- Energy-based models for anomaly detection score inputs by energy; unusual telemetry gets high energy.
- Combinatorial optimisation by simulated annealing samples a Boltzmann distribution while lowering the temperature, used for scheduling and planning.
- Physics links: Ising models, quantum annealers and Boltzmann sampling hardware share the same mathematics.
References
- D. H. Ackley, G. E. Hinton, T. J. Sejnowski (1985). “A learning algorithm for Boltzmann machines.” Cognitive Science 9(1).
- N. Le Roux, Y. Bengio (2008). “Representational power of restricted Boltzmann machines and deep belief networks.” Neural Computation 20(6).
- R. Salakhutdinov, G. Hinton (2009). “Deep Boltzmann machines.” Proc. AISTATS.
- S. Kirkpatrick, C. D. Gelatt, M. P. Vecchi (1983). “Optimization by simulated annealing.” Science 220.