The Information Bottleneck
A good representation of data should keep what matters for the task and throw away the rest. The information bottleneck (Tishby, Pereira and Bialek, 1999) makes this precise: compress into a representation that is as small as possible (low ) while staying as informative as possible about a target (high ). It is rate-distortion theory where the "distortion" is lost information about .
The objective
With the Markov chain (the representation sees only ), minimize over encoders :
A small favours compression (everything collapses into one cluster); a large favours keeping information about . By the data-processing inequality, always (The Data-Processing Inequality).
The iterative algorithm
For discrete variables the optimum satisfies self-consistent equations, solved by alternating updates like Blahut-Arimoto (Rate-Distortion Theory):
followed by recomputing and from the encoder.
import numpy as np
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 1e-15
return max(0.0, float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))) # clip rounding below 0
def information_bottleneck(Pxy, n_t, beta, rng, iters=300):
px = Pxy.sum(axis=1); py_x = Pxy / px[:, None]
enc = rng.dirichlet(np.ones(n_t), size=len(px)) # P(t | x)
for _ in range(iters):
pt = px @ enc
py_t = (enc * px[:, None]).T @ py_x / np.maximum(pt[:, None], 1e-15)
kl = np.sum(py_x[:, None, :] * np.log(py_x[:, None, :] / np.maximum(py_t[None, :, :], 1e-15)), axis=2)
logits = np.log(np.maximum(pt, 1e-15))[None, :] - beta * kl
enc = np.exp(logits - logits.max(axis=1, keepdims=True)); enc /= enc.sum(axis=1, keepdims=True)
Pxt = enc * px[:, None]
Pty = Pxt.T @ py_x
return mi(Pxt), mi(Pty), enc
# 8 values of x; y in {0, 1}; x values come in groups with similar P(y | x)
py1 = np.array([0.05, 0.1, 0.1, 0.5, 0.5, 0.55, 0.9, 0.95])
Pxy = np.column_stack([1 - py1, py1]) / 8
print(f"I(X;Y) = {mi(Pxy):.4f} bits, H(X) = 3 bits")
rng = np.random.default_rng(0)
for beta in [0.5, 2, 5, 20, 100]:
Ixt, Ity, enc = information_bottleneck(Pxy, 4, beta, rng)
print(f"beta = {beta:5}: I(X;T) = {Ixt:.4f}, I(T;Y) = {Ity:.4f}")I(X;Y) = 0.3729 bits, H(X) = 3 bits
beta = 0.5: I(X;T) = 0.0000, I(T;Y) = 0.0000
beta = 2: I(X;T) = 0.0000, I(T;Y) = 0.0000
beta = 5: I(X;T) = 0.8966, I(T;Y) = 0.2750
beta = 20: I(X;T) = 1.5572, I(T;Y) = 0.3683
beta = 100: I(X;T) = 1.5613, I(T;Y) = 0.3685
Below a critical value of (here between 2 and 5) the trivial solution, one cluster that ignores , is optimal. As grows, keeps more about and more about . The relevant information saturates near long before remembers all 3 bits of : most of the identity of is irrelevant to .
What the bottleneck learns
At moderate the encoder clusters values whose conditional distributions are similar: a representation that is "sufficient" for without copying .
import numpy as np
def information_bottleneck(Pxy, n_t, beta, rng, iters=300):
px = Pxy.sum(axis=1); py_x = Pxy / px[:, None]
enc = rng.dirichlet(np.ones(n_t), size=len(px))
for _ in range(iters):
pt = px @ enc
py_t = (enc * px[:, None]).T @ py_x / np.maximum(pt[:, None], 1e-15)
kl = np.sum(py_x[:, None, :] * np.log(py_x[:, None, :] / np.maximum(py_t[None, :, :], 1e-15)), axis=2)
logits = np.log(np.maximum(pt, 1e-15))[None, :] - beta * kl
enc = np.exp(logits - logits.max(axis=1, keepdims=True)); enc /= enc.sum(axis=1, keepdims=True)
return enc
py1 = np.array([0.05, 0.1, 0.1, 0.5, 0.5, 0.55, 0.9, 0.95])
Pxy = np.column_stack([1 - py1, py1]) / 8
enc = information_bottleneck(Pxy, 4, 20, np.random.default_rng(0))
clusters = enc.argmax(axis=1)
relabel = {c: i for i, c in enumerate(dict.fromkeys(clusters.tolist()))}
for x in range(8):
print(f"x = {x} P(y=1|x) = {py1[x]:.2f} -> cluster {relabel[int(clusters[x])]}")x = 0 P(y=1|x) = 0.05 -> cluster 0
x = 1 P(y=1|x) = 0.10 -> cluster 0
x = 2 P(y=1|x) = 0.10 -> cluster 0
x = 3 P(y=1|x) = 0.50 -> cluster 1
x = 4 P(y=1|x) = 0.50 -> cluster 1
x = 5 P(y=1|x) = 0.55 -> cluster 1
x = 6 P(y=1|x) = 0.90 -> cluster 2
x = 7 P(y=1|x) = 0.95 -> cluster 2
The eight inputs fall into three clusters, one per level of : low, middle and high.
The bottleneck and deep learning
Tishby and colleagues proposed viewing each layer of a neural network as a representation on the information plane , and suggested that training first fits (raises ) and then compresses (lowers ). Later work showed the compression phase depends on the activation function and on how mutual information is estimated, so the picture is debated. The variational information bottleneck turns the objective into a trainable loss with a KL penalty, closely related to the variational autoencoder, and is used as a regularizer.
In software
- The variational information bottleneck adds to a classification loss, with a Gaussian encoder, which is easy to write in any deep-learning framework.
- For discrete data, the iterative algorithm above clusters words by their context distributions (distributional clustering) and documents by their word distributions.
Exercises
Exercise 1: Extremes
What does the bottleneck solution look like for , and for ?
Answer
: a single cluster, . : keeps all relevant information, .
Solution
With no reward for relevance, any information about is pure cost. With an enormous reward, the encoder separates every pair of inputs with different .
Exercise 2: An upper bound
Can ever exceed ?
Answer
No.
Solution
is computed from alone, so is a Markov chain and the data-processing inequality applies.
Exercise 3: Sufficient clustering (code)
Merge the inputs of the lesson's example into the three groups {0, 1, 2}, {3, 4, 5}, {6, 7} and compute and for this deterministic .
Answer
bits, almost all of , with bits: the same point the algorithm found at .
Solution
import numpy as np
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 0
return float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))
py1 = np.array([0.05, 0.1, 0.1, 0.5, 0.5, 0.55, 0.9, 0.95])
Pxy = np.column_stack([1 - py1, py1]) / 8
groups = np.array([0, 0, 0, 1, 1, 1, 2, 2])
Pty = np.array([Pxy[groups == g].sum(axis=0) for g in range(3)])
Pxt = np.zeros((8, 3)); Pxt[np.arange(8), groups] = 1 / 8
print(round(mi(Pty), 4), round(mi(Pxy), 4), round(mi(Pxt), 4))0.3685 0.3729 1.5613
Test yourself
The information bottleneck trades off…
- compression against relevance
- accuracy against speed
- entropy against variance
- bias against capacity
Which inequality guarantees ?
- the data-processing inequality
- Kraft's inequality
- Fano's inequality
- the Hamming bound
At moderate beta, the discrete bottleneck tends to…
- cluster inputs with similar
- copy X exactly
- ignore X completely
- maximize H(T)