Skip to content

Deterministic Annealing

This demo takes a few seconds to load and runs entirely in your browser (NumPy, SciPy and matplotlib via Pyodide; no tgmm or PyTorch involved).

EM can get stuck when its components start on top of each other. Deterministic annealing EM (Ueda & Nakano, 1998) tempers the E-step with an inverse temperature \(\beta\in(0,1]\):

\[ r_{ik}(\beta)=\frac{\big(\pi_k\,\mathcal N(x_i\mid\mu_k,\Sigma_k)\big)^{\beta}}{\sum_j\big(\pi_j\,\mathcal N(x_i\mid\mu_j,\Sigma_j)\big)^{\beta}}, \qquad \beta_t=\begin{cases}\beta_0^{\,1-t/n_{\text{anneal}}}, & t<n_{\text{anneal}}\\ 1, & t\ge n_{\text{anneal}}.\end{cases} \]

Small \(\beta\) spreads every point's responsibility over all components (a smooth, nearly unimodal objective); \(\beta\) then rises geometrically to 1 over \(n_{\text{anneal}}=30\) iterations. Below, three Gaussians are fitted to three well-separated blobs from a saddle start: all three means are jittered (σ = 0.3) around the same blob, each with covariance \(I\) -- a classic EM failure mode (a poor local optimum that plain EM never leaves). Pick \(\beta_0\) and the algorithm, then press the button to restart from a fresh jitter.

Final mean log-likelihood: annealed -3.870 vs. β = 1: -4.380 (difference +0.510). Recent runs (algorithm, β₀, jitter seed, annealed LL, β = 1 LL)

What to look for

  • EM, β₀ ≈ 0.7 (default): the tempered E-step lets the components see more than the blob they started on, and this jitter ends in the three-blob solution (higher log-likelihood), while plain EM at \(\beta=1\) settles in a poor local optimum. The right-hand plot shows how the entropy of the assignments evolves as \(\beta\to1\) (dotted line: end of annealing).
  • It is a heuristic, not a guarantee. Press the button a few times: with other jitters annealing ties, or even loses to plain EM. And too hot a start collapses the fit: for \(\beta_0\lesssim0.3\) the means are pulled together until all three components describe the same blob (log-likelihood far below either alternative). A near-symmetric state stays symmetric under tempering, so annealing needs some real asymmetry in the start to amplify.
  • CEM: assignments are hard, and \(\arg\max_k r_{ik}(\beta)\) does not depend on \(\beta>0\), so annealing has no effect (this is also what tgmm does: the C-step follows the tempered E-step).
  • This page mirrors tgmm's loop: the convergence test is only applied once \(\beta=1\), and the reported value is the true mean log-likelihood of the final fit (while \(\beta<1\), tgmm records the tempered normaliser).

See the Stochastic EM, Annealing & SAEM tutorial for the same idea with tgmm.