Interactive figures
Every figure in the track. Each one is a small experiment: drag, slide, and watch the numbers. The link under each figure takes you to the lesson that explains it.
Lesson 1 · Surprise, bits and entropy
Slide and watch the yellow point move on the blue curve . Press Halve p a few times: each press adds exactly one bit. The faint point at is always one bit higher. Switch to two independent outcomes: the surprisal of "both happen" (probability ) is the sum of the two surprisals. The log scale axis turns the curve into a straight line.
Press Play once to draw a hidden outcome and follow its path in the question tree (yellow). Then press Play 100 games a few times: the running average settles at the expected number of questions of the tree (grey line). For this equals the entropy bits (blue line). Try the strategy split the list in half: it needs 2 questions. Then try the distribution : even the best tree needs more than , because surprisals such as bits are not whole numbers.
Drag the tops of the blue bars (the probabilities); the other bars rescale so the total stays 1. The yellow bars below are the contributions of each outcome; their sum is the entropy . Use one-hot and uniform to reach the two extremes and (the dashed line in the meter). Notice that a tiny probability contributes almost nothing, and so does a probability close to 1.
Drag the first bar from 0 to 1. The yellow point runs along the binary entropy curve (blue). Notice the symmetry around and how fast the curve rises near the ends.
Lesson 2 · Joint and conditional entropy
Choose an example and press Play once. The blue questions find the first variable; the yellow questions then find the second variable given the first. The readout compares the average number of questions of each stage with and . Try a coin and its copy: stage 2 needs no question. Then try weather: rain first: the entropies still add up, but whole questions cannot match surprisals that are not whole numbers.
Edit the weights or choose an example. Each row of the table is divided by its sum to give the bars and the row entropy (blue). The grey bottom row is the marginal with , also drawn as the dashed line. The yellow bar is , the average of the row entropies weighted by . Notice: one row can reach past the dashed line, but the yellow bar never does.
Move the flip probability . is a coin with , and is with probability and flipped with probability . The second bar is , split into and the shared part ; the third bar is , split into and . At the bars overlap completely; at they do not overlap at all. Also try the weather table.
Lesson 3 · Jensen and KL divergence
Drag the blue points along the curve and move the weight sliders. The yellow dot is the centre of mass ; the small dot on the curve is . The aqua segment is the Jensen gap. For a convex the yellow dot is always above the curve; switch to or and it is always below. Put all the weight on one point: the gap closes.
Drag the tops of the bars to change the true distribution (blue) and the model (orange). The lower chart shows each term (aqua): some terms are negative, but their sum is never below 0. Switch the lower chart to the terms of and compare the two totals. Then drag one orange bar to 0 where the blue bar is not 0.
Move (the true coin) and (the model coin). The aqua curve is as a function of ; the grey dashed curve is the reverse, . Both touch 0 only at . Near or the aqua curve shoots up to infinity, but the dashed one stays finite. Try the preset .
Lesson 4 · Cross-entropy as a loss
Drag the orange bars (the model ) against the fixed blue bars (the data ). The stacked bar shows the cross-entropy as (blue) plus (aqua). The blue part does not move when you change . The aqua part becomes 0 only when the orange bars match the blue bars, so is the floor. Change the data with the presets.
Move the slider for the probability the model gives to the true class. The aqua curve is the log-loss ; the grey dashed curve is the squared error ; the light grey step is the 0–1 loss of the predicted class (two classes). The yellow line marks the current value. On the right, compare the gradients with respect to the logit: for a confident mistake, only the log-loss still pushes hard.
Move the logit sliders and choose the true class. The orange bars are the softmax probabilities ; the blue outline is the one-hot target ; the dark arrows are the gradient on each logit. The arrow on the true logit points down (the gradient is negative, so gradient descent raises that logit); the others point up. The arrows always add up to 0. Raise the temperature to see a flatter and a smaller gradient.
Choose a target: one-hot, label smoothing (slider ) or a teacher at temperature . The blue bars are the target and the orange bars the student . The stacked bar splits the loss into and . With a one-hot target, a larger always lowers the loss. With label smoothing, the loss is smallest at a moderate , and a very confident student (large ) has a larger loss.
Move the loss slider and read the same number as bits, perplexity and bits per byte. The curve is the perplexity on a log scale; the yellow dot is the current model. Try the preset "uniform over 50 257 tokens". Switch to the image model to convert an NLL per image into bits per dimension.
Lesson 5 · Compression is prediction
Pick a symbol, then click a node of the tree to give that symbol this codeword. The bar below the tree shows the interval of each codeword in ; its length is the codeword's share of the budget (orange, the code's model). The blue bar shows the probabilities for comparison. Watch the Kraft sum and the average length against the entropy . Try "not prefix-free": two intervals overlap (yellow) and the code cannot be decoded instantly.
Move the slider to change the coin's probability of heads. The dots are the bits per flip of the best (Huffman) code for blocks of flips. They stay between the entropy (blue line) and the bound (magenta). Notice that the rate does not always go down when grows (for , is a little worse than ); only the bound does. At there is nothing to gain: bit already.
Press Next merge to run Huffman's algorithm one step at a time. The two yellow nodes are the two smallest weights; they merge into a new node one level up. At the end, read each codeword along the path from the root (left = 0, right = 1). The table compares each length with the surprisal , and the readout compares with the entropy (blue). Edit the probabilities, or try the preset with ties.
Add symbols with the buttons and watch the interval shrink. Each row zooms into the piece kept in the row above (yellow); the piece sizes are the model's probabilities . The readout gives the final width , the ideal length , and the real codeword. Switch the model: a model that predicts the sequence well keeps wide intervals and needs few bits. "Learns from counts" is an adaptive model that updates its probabilities after every symbol.
Drag the bar tops of the true distribution (blue) and the model (orange). The lower chart shows the average code length when the data come from and the code is built for : the entropy (blue), the extra cost of the wrong model (aqua), and the rounding cost of whole-number Shannon lengths (yellow). Set : the aqua part disappears.
Lesson 6 · Differential entropy and KL fits
Make the bins smaller with the slider. Top: the density (blue) and the histogram of (yellow, bin probability divided by ). Bottom: grows by about 1 bit per halving of , while (grey, dashed) settles at ; the aqua gap is . Then press "σ = 0.2" and notice that the density goes above the dashed line at 1 and becomes negative.
Press "Fit forward KL", then "Fit reverse KL". The blue target is ; the orange curve is the Gaussian . Drag its peak to choose a start (left and right move , up and down change ), or use the "Start" buttons. Notice: the forward fit always ends at the same wide Gaussian. The reverse fit ends on the bump nearest to the start, and the two KL values show that each fit is good only for its own objective.
Change , and the correlation . The blue ellipse is the ellipse of ; its area is and the readout gives . Push towards : the ellipse flattens and . Then move or : the yellow dashed ellipse is with , a change of units, and shifts by .
Guess the order first, then switch the compared shape. All four densities have variance . The Gaussian has the largest ; the compared shape is yellow, and the aqua gap is . Move : every shifts by , but the gaps stay the same.
Press "Forward fit" and "Reverse fit". Blue: the and ellipses of the correlated target . Orange: the factorized . The forward fit matches the marginal variances and spills into the empty corners; the reverse fit shrinks to the conditional variances and stays inside . Move to 0: both fits agree.
Lesson 7 · Mutual information
Move the flip probability . Left: the channel; the arrow widths are the transition probabilities. Middle: the bar is split into and the shared part ; the bar is split into and . Right: the violet curve and the current point. Notice that is as good as . Then move the input bias : the information drops below the violet curve.
Edit the weights of the joint table, or try the presets. Left: the joint (blue). Middle: the product of its marginals (orange), the "independent version". Right: each cell's contribution in bits, violet when positive and grey when negative. Their sum is . Make all rows proportional and watch become 0. Try "": the correlation of this pair is 0, but is not.
Apply or to the samples. The true mutual information does not change: the maps are invertible. The sample correlation drops, and the Gaussian formula with (orange) gives a wrong value, because the transformed data are not jointly Gaussian. The entropy of the horizontal coordinate changes too. Move to see how grows as .
Choose how is made from . The bars are , and (grey); the aqua segment is the information about that the processing lost. Try every option and both sliders: the yellow bar is never longer than the violet one. The copy and the relabelling (both invertible) lose nothing; a constant loses everything.
Change and , then switch to "weak dependence". The magenta histogram shows 400 plug-in estimates; its mean is the magenta line. The blue line is the true , and the aqua dashed line is the true plus the predicted bias . The yellow line is one data set, with its permutation p-value. Notice: with and the bias is large; with large the estimates concentrate at the truth.
Lesson 8 · InfoNCE and contrastive learning
Press "Draw samples and fit the classifier". The blue density is (label 1) and the orange one is (label 0). The lower chart shows the true log ratio (dark line) and the logit of a logistic classifier fitted on the features (dashed). Notice that the two curves agree between the dashed grey lines, where both classes have samples. Try "different widths": the true log ratio becomes a parabola. With 30 samples per class, look at how the fit goes wrong far from the data.
Move the slope . The dark curve is the generator (here of KL). The magenta line with slope stays below the curve; it touches it at the yellow dot and crosses the vertical axis at . The aqua segment at the ratio is the gap: it is never negative. Press "Use the best slope at u" and the gap becomes 0. Press "Show many tangent lines" to see rebuilt as the envelope of its lines. Switch to TV and notice the kink at .
Change the true MI with and . Each magenta dot is the estimate from one batch of correlated Gaussian pairs, with the optimal critic. The violet line is the true MI, , and the dashed line is . Use "Try": at low MI the three estimators agree. At high MI, notice that InfoNCE has a small spread but stops below , while NWJ and DV are not capped but spread widely, and their mean is often above the truth.
Each row is a classification over the batch. Cell is darker when the softmax of row gives more probability to candidate ; the framed diagonal holds the true partners. The bars compare the true MI (violet) with the InfoNCE bound (magenta) and the ceiling (dashed). Raise to 0.99 and to 10: the bound stops at . Then increase . Choose the constant critic: the rows become uniform and the bound is 0.
Move the generator. The data density is blue, the generator density is orange, and the dark curve is the optimal discriminator . The lower chart shows the GAN value at as a function of the generator mean (magenta), with the current as a yellow dot. Notice: the integral and agree to 4 digits. Move to 6: the curve is flat and the slope is almost 0.
Lesson 9 · The ELBO and VAEs
Move and watch the magenta ELBO curve under the dashed ceiling . The aqua gap is 0 only at the blue posterior value . The side panel shows that the gap equals , computed separately. Try the other joints, and the end points and .
Move the mean and the variance of and compare it with the posterior. The posterior lies between the prior (dashed grey, centred at 0) and the likelihood (thin dark line, centred at 2). The two number lines show the same ELBO in two ways: minus the gap, and the reconstruction term minus the KL to the prior. Notice that has the best reconstruction but pays a large KL to the prior.
Change the decoder noise and the decoder weight . The encoder is always the exact posterior, so the ELBO equals the average log-likelihood. It is the reconstruction term (dark line) minus the KL to the prior. The yellow line marks the best . Push to 1 or above: the best becomes 0, the KL term becomes 0, and the latent is unused.
Increase and watch two things. Top: the orange histogram of 1000 estimates becomes narrow, and its average (≈ ) moves up toward the dashed ceiling . Some single estimates land above the ceiling. Bottom: the gap against on log-log axes approaches the dashed line. Change the proposal : the gap is 0 for every when is the posterior .
Lesson 10 · Rate–distortion and β-VAE
Move the slider and compare the limit (magenta) with the store-or-guess line (orange). The aqua bar is the gain of coding long blocks. Then change : the curve starts at the lossless limit and reaches 0 at , where you can always output the more likely symbol.
Move the slider along the curve . The lower chart shows a sample signal and a reconstruction drawn from the optimal test channel with that mean squared error; the aqua bars are the errors. Halve the bits and watch the errors grow. Then show the quantizer points: a uniform scalar quantizer followed by an ideal entropy coder stays about 0.25 bits above the curve.
Move the water level (yellow). Each blue bar is the variance of one component; the aqua part is its distortion , and the number above the bar is its rate in bits. Notice that every coded component ends with the same error , and that small components are dropped. Try the spectrum of the digits data set: its top principal components have similar variances.
Press 1 step a few times, then 25 steps. The yellow point is the current channel; it moves onto the curve and stops where the dashed line of slope touches the curve. The table on the right is the test channel (darker orange = larger). Move and run again to land on another point. Try the 3-level source with squared error.
Move the encoder sliders and . The orange point is (MSE, rate) and the violet point is (MSE, ); the aqua bar between them is . The violet point always lies on the curve. Then move : the yellow point is the β-VAE optimum, where the dashed line of equal loss touches the curve. Press Go to the β-optimum, and try to see posterior collapse.