Implement the toy model of Elhage et al. with manual gradients, train it at several sparsities, and measure how many features it packs into the hidden dimensions.
toy_forward(X, W, b)
X is (B, n), W is (m, n) with , b is (n,). Hidden H = X @ W.T (B, m), pre-activation Z = H @ W + b, reconstruction Xhat = max(Z, 0). Return (H, Z, Xhat).toy_loss_and_grads(X, W, b, importance)
(loss, dW, db) with the exact gradients: with of shape (B, n), the bias gradient is the column mean of and the weight gradient is , the sum of the decompression path and the compression path.sample_features(rng, B, n, sparsity)
sparsity, otherwise uniform on [0, 1): draw rng.random((B, n)) for the values and rng.random((B, n)) < sparsity for the mask, in that order.train_toy(rng, n, m, sparsity, importance, steps, lr, batch=256)
W from one rng.normal draw of shape (m, n) scaled by 0.1, and b as zeros of length n (draw W before any batch), then plain gradient descent for steps steps on fresh batches from sample_features. Return (W, b, final_loss).dims_per_feature(W)
toy_loss_and_grads against a finite difference on a tiny instance before training.Z, not to the loss.dims_per_feature well below one; dense inputs keep it near one.