# From SLT to AIT: NN generalisation out-of-distribution

**TL;DR:** *This post derives an upper bound on the prediction error of Bayesian learning on neural networks. Unlike the bound from vanilla Singular Learning Theory (SLT), this bound also holds for out-of-distribution generalization, not just for in-distribution generalization. Along the way, it shows some connections between SLT and Algorithmic Information Theory (AIT).*

*Written at Goodfire AI*

Introduction
============

Singular Learning Theory (SLT) describes Bayesian learning on neural networks. But it currently has some limitations. One of these limitations is that it assumes model training data are drawn independently and identically (IID) from some distribution, making it difficult to use SLT to describe out-of-distribution (OOD) generalization. For example, if we train a model to classify pictures of animals taken outdoors, it's very difficult to use vanilla SLT to reason about whether this model will generalize to correctly classify pictures of animals taken indoors. Vanilla SLT also assumes that the model has been trained on an asymptotically infinite number of data points.[^dajyj8gdh0n]

Another theory about Bayesian learning is Algorithmic Information Theory (AIT), which describes Solomonoff induction (SI) \[[1](https://www.lesswrong.com/posts/Kyc5dFDzBg4WccrbK/an-intuitive-explanation-of-solomonoff-induction),[2](https://www.lesswrong.com/posts/EL4HNa92Z95FKL9R2/a-semitechnical-introductory-dialogue-on-solomonoff-1)\].[^83p43t4mm16] Solomonoff induction is Bayesian learning over an (infinite) ensemble of programs. It is, unfortunately, uncomputable. But it does *not* require an IID sampling assumption, does *not* rely on asymptotically infinite data, and *does* describe OOD generalization. AIT is also older, more developed, and more established than SLT. A lot of agent foundations work builds on the AIT framework.

So if we could derive an AIT-style description of Bayesian learning on neural networks, that description might tell us things about neural network generalization out-of-distribution.

Here, we:

1.  Derive error bounds for a computationally bounded Solomonoff induction (SI).
    1.  First, we import Solomonoff induction to the learning-theoretic setting of data coming in input-label pairs $(x,y)$, with the inductor trying to predict the labels $y$ conditional on the inputs $x$ and show that the standard error bound for SI still holds there.
    2.  Then, we define a bounded, computable form of induction over programs. We show that it still satisfies a weaker SI-style error bound. We also show that this bounded induction is still somewhat invariant to our choice of universal Turing machine.
2.  Derive a bound on the expected prediction error of Bayesian learning on neural networks.
    1.  Specifically, we derive an error bound for Bayesian learning over parametrized functions, starting from a uniform prior over real-valued parameters. In contrast to SLT-style error bounds, we do not need to assume that our data are drawn IID. Hence the bound will also hold under distributional shifts.
    2.  We show how this error bound relates to the notion of $\epsilon$-volumes that define the learning coefficient in Singular Learning Theory.

The first part is mainly supposed to build intuition for the second, and help people see how the AIT picture and Bayesian learning on neural networks connect.[^ixa6eerf2w]

I also hope that this post might help readers used to thinking about probability from a more [E. T. Jaynes-esque](https://www.lesswrong.com/posts/KN3BYDkWei9ADXnBy/e-t-jaynes-probability-theory-the-logic-of-science-i)/native-Bayesian point of view a little with grokking Singular Learning Theory, which is usually described in a pretty [stat-mech-esque](https://en.wikipedia.org/wiki/Statistical_mechanics)/second-language-Bayesian [manner](https://www.lesswrong.com/posts/puv8fRDCH9jx5yhbX/johnswentworth-s-shortform?commentId=cGSwj7AfLFEbw4Qh7).

Prediction error bounds for a computationally bounded Solomonoff induction
==========================================================================

Claim 1: We can import Solomonoff induction into the learning-theoretic setting
-------------------------------------------------------------------------------

We consider a prediction setting with inputs $x_n\in \{0,1\}^*$ (finite binary strings) and labels $y_n\in \{0,1\}$. We assume that the labels were generated by a probabilistic program $\mu$ [^zdbrwjjlysa], i.e., $P_\mu(y_n\mid x_n)$ is set by $\mu(x_n)$. We are given $N \geq 1$ such input-label pairs $\{(x_n, y_n)\}_{n=1}^N$.

Our goal is to construct an inductor that predicts whether $y_n$ is $1$ given $x_n$, using Bayesian updating on past input-label pairs $(x_{1},y_{1}),\dots,(x_{n-1},y_{n-1})$ that it has already seen. To do this, we will just slightly modify the standard Solomonoff setup for probabilistic programs.

Let $M_1$ be a plain[^5e0ynigxxx] monotone[^w0xqpoxf9u] [universal Turing machine](https://en.wikipedia.org/wiki/Universal_Turing_machine) (UTM) with a binary alphabet, one-way read-only input and output tapes, and a two-way work tape. We define the set of all programs $p$ of length $T\in \mathbb{N}$ bits, and the set of augmented programs $p_n := (p_{\text{read}}, x_n, p)$, where $p_{\text{read}}$ is some 'read-in' program that first copies $x_n$ from the input tape to the first $L_{\text{in}}$ cells of the work tape, then sets the read head to the first bit of the program string $p$ and finally resets the UTM's internal state to its starting configuration.

Our inductor then makes its predictions using the ensemble of augmented programs: 

$$
\begin{equation} P_{M_1}(y_n\mid x_n, \mathcal{D}_{<n})=\sum_{p}  P_{M_1}(y_n \mid p_n) P(p\mid \mathcal{D}_{<n})\,, \end{equation}
$$

 where $P_{M_1}(y_n=1 \mid p_n)=M_1(p_n)=M_1(p_{\text{read}},x_n,p)$ is the output bit string of our UTM on input string $p_n$ interpreted as the probability that $y_n=1$[^turt1epal9], $P_{M_1}(y_n=0 \mid p_n)=1-P_{M_1}(y_n=1 \mid p_n)$ and $P(p\mid \mathcal{D}_{<n})$ is the probability we assign to program $p$ after updating on the past prediction performance of $p_{n-1},\dots,p_{1}$ on the input-label pairs $(x_{n-1},y_{n-1}),\dots,(x_{1},y_{1})$. For our starting prior $P(p\mid \mathcal{D}_{<1})=P(p)$, we take the uniform distribution $P(p)=2^{-T}$ over our set of programs $p$.

Note that this setup does not make any assumptions about how the inputs $x_n$ are sampled. This is in contrast to the Singular Learning Theory (SLT) setup, which needs to assume that the inputs $x_n$ are sampled IID from some underlying distribution. This assumption makes it difficult to use SLT to say anything about the generalization behavior of a trained network under distributional shifts, such as switching from the training distribution to a very different deployment distribution. We do not have that problem here.

### **Claim**

So long as the program that generated the data $\mu$ has a minimum length less than or equal to $T$ on our UTM $M_1$, $C(\mu,M_1)\leq T$, the conventional error bound for Solomonoff induction still applies in this setting. i.e., the total expected prediction error of our inductor will be bounded by 

$$
\begin{equation} \sum^{N}_{n=1} H(P_{\mu}(\cdot\mid x_n),P_{M_1}(\cdot\mid x_n, \mathcal{D}_{<n}))\leq C(\mu,M_1)+ \sum^N_{n=1} H(P_\mu(\cdot\mid x_n))\,, \tag{1.1}\end{equation}
$$

 for all $N\in\mathbb{N}_{>0}$. In other words, the inductor's total expected prediction error over the first $N$ data it sees, scored in bits of [cross-entropy](https://en.wikipedia.org/wiki/Cross-entropy) 

$$
\begin{equation} \sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n),P_{M_1}(\cdot\mid x_n, \mathcal{D}_{<n})):=-\sum^N_{n=1} \sum_{y_n} P_{\mu}(y_n\mid x_n) \log_2 P_{M_1}(y_n\mid x_n, \mathcal{D}_{<n}) \end{equation}
$$

 is bounded to stay below the [Kolmogorov complexity](https://www.lesswrong.com/w/kolmogorov-complexity) of the data-generating process $\mu$ on $M_1$, $C(\mu,M_1)$, meaning the minimum description length of the program $\mu$ on the machine $M_1$, plus the [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_(information_theory)) $H(P_\mu(\cdot\mid x_n))$ of $\mu$ on each data point $x_n$ summed:[^8b582udqgib]

$$
\begin{equation} \sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n)):=-\sum^N_{n=1} \sum_{y_n} P_{\mu}(y_n\mid x_n) \log_2 P_{\mu}(y_n\mid x_n) \,. \end{equation}
$$

### **High-level proof summary**

The proof works analogously to the derivation of the bound in the conventional SI setup found in most textbooks. The only differences are that

1.  We have not taken program length $T$ to infinity, as is done in the universal prior. We just assume that it is set to some number larger than $C(\mu,M_1)$.
2.  $M_1$ is a plain UTM rather than a prefix-free UTM, and thus our starting prior over programs is just uniform, rather than falling off exponentially with program length. The degeneracy of program implementations ensures that simpler programs are exponentially preferred; we don't need to insert a term favoring simpler programs in the prior by hand.
3.  Our programs $p_n=(p_{\text{read}},x_n,p)$ start with a prefix $(p_{\text{read}},x_n)$, where $x_n$ changes between data points.

None of these changes affect the structure of the proof much. We rearrange the expression for $\sum_n H(P_\mu(\cdot\mid x_n),P_{M_1}(\cdot\mid x_n,\mathcal{D}_{<n}))$ to make its dependence on the prior $P(p)$ manifest, then use the existing result that the implementation of program $\mu$ must be assigned probability $\geq 2^{-C(\mu,M_1)}$ in the prior due to degeneracy of implementation. I.e., there are at least $2^{T-C(\mu,M_1)}$ programs of length $T$ that give the same output as $\mu$ on all data, since we can just append $T-C(\mu,M_1)$ arbitrary 'garbage bits' to the shortest implementation of $\mu$ to increase its length to $T$ without affecting the computation. So, the total probability mass in $P(p)$ assigned to programs that output the same probability as $\mu$ on all data must be at least $\frac{2^{T-C(\mu,M_1)}}{2^T}=2^{-C(\mu,M_1)}$.

+++ **Proof**

First, we rearrange our expression for the total cross-entropy: 

$$
\begin{equation} \begin{aligned} &\sum^{N}_{n=1}H(P_\mu(\cdot\mid x_n),P_{M_1}(\cdot\mid x_n,\mathcal{D}_{<n}))=-\sum^{N}_{n=1}\sum_{y_n} P_\mu(y_n\mid x_n)\log_2\left(P_{M_1}(y_n \mid x_n,\mathcal{D}_{<n})\right) \ &= -\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\sum_{p}  P_{M_1}(y_N \mid p_N) P(p\mid \mathcal{D}_{<N})\right)\ &\quad-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\sum^{N-1}_{n=1}\log_2\left(P_{M_1}(y_n \mid x_n,\mathcal{D}_{<n})\right) \ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\sum_{p}  \frac{\prod^N_{n=1}P_{M_1}(y_n \mid p_n)}{\prod^{N-1}_{n=1} P_{M_1}(y_{n}\mid x_{n}, \mathcal{D}_{<n})}P(p)\right)\ &\quad-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\sum^{N-1}_{n=1}\log_2\left(P_{M_1}(y_n \mid x_n,\mathcal{D}_{<n})\right)\ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\sum_{p} P_{M_1}(y_N \mid p_N) \dots P_{M_1}(y_{1}\mid p_{1})  P(p)\right)\ \end{aligned} \end{equation}
$$

In the second equality, we used the assumption that our inductor adjusts its probabilities according to incoming evidence using Bayesian updating. 

According to [result 3.8.1 in this book](https://www.hutter1.net/ai/uaibook2.htm), the semimeasure for programs on a monotone, plain UTM matching the outputs of a program $\mu$ must be $\geq 2^{-C(\mu,M_1)}$. Inserting this bound yields: 

$$
\begin{equation} \begin{aligned} &\sum^{N}_{n=1}H(P_\mu(\cdot\mid x_n),P_{M_1}(\cdot\mid x_n, \mathcal{D}_{<n}))\ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\sum_{p} P_{M_1}(y_N \mid p_N) \dots P_{M_1}(y_{1}\mid p_{1})  P(p)\right)\ &\leq -\sum_{y_{N},\dots,y_1} P_\mu(y_{n}\mid x_n)\dots P_\mu(y_1\mid x_1) \log_2\left(2^{-C(\mu,M_1)}P_\mu(y_N\mid x_N)\dots P_\mu(y_1\mid x_1)\right)\ &=C(\mu,M_1)+\sum^N_{n=1} H(P_\mu(\cdot\mid x_n))\,. \end{aligned} \end{equation}
$$




+++

$$

Claim 2: A bounded induction still efficiently predicts efficiently predictable data
------------------------------------------------------------------------------------

### **Setup**

Now, we're going to modify the setup from the previous section, bounding our induction to make it computable. Instead of running programs $(p_{\text{read}},x_n,p)$, where $p$ is drawn from the set of all bit strings of length $T$, we restrict ourselves to programs of length $T$ that require a maximum of $s$ space and a maximum of $t$ time steps. 

Specifically, we construct a new bounded UTM $M_2$ from our UTM $M_1$. $M_2$ only has $s+1$ cells of work tape available. If the head moves to the last cell of the work tape, $M_2$ immediately halts. Further, $M_2$ always halts itself after $t$ execution steps if it has not halted yet. This bounded induction will no longer be optimal in the sense of having an SI-style bound on its total error that depends only on the entropy and Kolmogorov complexity of the data-generating process $\mu$, because $\mu$ might not be computable in time $t$ and space $s$.

### **Claim**

Our bounded induction still has a weaker upper bound on its total expected prediction error: If there is some program $\mu^*$ that is an "*efficient predictor*" of $\mu$, in the sense that $\mu^*$ approximates the probability assignments of $\mu$ up to some error we deem 'acceptable', our induction will predict the data as well as this efficient predictor, up to an offset equal to the efficient predictor's description length.

Specifically, for any program $\mu^*$ included in the set of programs our bounded induction runs over, we have the bound:[^xd0gyg0on0i]

$$
\begin{equation} \begin{aligned}\sum^{N}_{n=1} H(P_\mu(\cdot\mid x_n),P_{M_2}(\cdot\mid x_{n},\mathcal{D}_{<n}))\leq& C(\mu^*,M_2)\&+\sum^{N}_{n=1}H\left(P_\mu(\cdot\mid x_n),P_{\mu^*}(\cdot\mid x_n)\right)\,, \end{aligned}\tag{1.2} \end{equation}
$$

 for all $N\in\mathbb{N}_{>0}$. So, for any program $\mu^*$ with minimum description length $\leq T$ on $M_2$ that is computable in time $t$ and space $s$, the computationally bounded induction will have its total prediction error bounded by the prediction error of $\mu^*$ plus the minimum description length of $\mu^*$ on $M_2$.

+++ **Proof**

Proceeds completely analogously to the proof for Claim 1, except that we substitute in $P_{\mu^*}(y_n\mid x_n)$ instead of $P_{\mu}(y_n\mid x_n)$. So we won't write it out again.




+++

Because 

$$
\begin{equation} \begin{aligned} &\sum^N_{n=1}H\left(P_\mu(\cdot\mid x_n),P_{\mu^*}( \cdot\mid x_n)\right)=\sum^N_{n=1}H(P_\mu(\cdot\mid x_n))+\sum^{N}_{n=1}D_{\text{KL}}(P_\mu(\cdot\mid x_n),P_{\mu^*}(\cdot\mid x_n))\,,\ \end{aligned} \end{equation}
$$

the only difference between this bound and the bound for the computationally unbounded induction from Equation (1.1) is an additional term $\sum^{N}_{n=1}D_{\text{KL}}(P_\mu(\cdot\mid x_n),P_{\mu^*}(\cdot\mid x_n))$, the KL divergence between the data-generating process $\mu$ and the program $\mu^*$, summed over all input-label pairs. 

Why would we suppose that a program $\mu^*$ that gets low prediction error with limited compute exists? Well, for some problems, an efficient predictor probably *doesn't* exist. But empirically, we can do pretty well on many prediction problems we encounter in the real world using an amount of compute that's practically feasible to obtain. Why that is, I don't know. Perhaps it is somehow related to why a lot of the world seems to [abstract well](https://www.lesswrong.com/w/natural-abstraction).

Claim 3: The bounded induction is still somewhat invariant under our choice of UTM
----------------------------------------------------------------------------------

Given any program $\mu^*$ that can run on a plain, monotone, bounded UTM $M_3$ in space $s$ and time $t$, we can run it on some other plain, monotone, bounded UTM $M_2$ in space $\mathcal{O}(s)$ and time $\mathcal{O}( t \log_2(t))$.[^9pcfd24lrkg] Thus, the Kolmogorov complexity $C(\mu^*,M_3)$ of $\mu^*$ on $M_3$ is bounded by 

$$
\begin{equation} \begin{aligned} &C(\mu^*,M_3)\leq C(\mu^*,M_2)+ C(M_2,M_3) \end{aligned} \end{equation}
$$

 provided $M_3$ has sufficient computational resources available, because we can just simulate $M_2$ on $M_3$ and then run $\mu^*$ on the simulated $M_2$.

Therefore, our total prediction error for bounded induction on any other plain monotone UTM $M_3$ bounded to $s'\geq c_s s$ space and $t'\geq c_t t \log_2(t)$ time, where $c_s,c_t\geq1$ are the constant prefactors for simulating $M_2$ on $M_3$, will still be bounded by 

$$
\begin{equation} \begin{aligned} \sum^{N}_{n=1}H(P_\mu(\cdot\mid x_n),P_{M_3}(\cdot\mid x_n, \mathcal{D}_{<n}))\leq& \,C(\mu^*,M_2)+C(M_2,M_3)\&+\sum^{N}_{n=1}H\left(P_\mu(\cdot\mid x_n),P_{\mu^*}(\cdot\mid x_n)\right)\,. \end{aligned}\tag{1.3} \end{equation}
$$

 for all $N\in\mathbb{N}_{>0}$. So, our choice of UTM matters somewhat, since we might need more space and execution time on a different UTM to implement an equally efficient predictor. However, converting to a different UTM only increases the required execution time from $t$ to $\mathcal{O}(t \log_2(t))$ and the required space from $s$ to $\mathcal{O}(s)$. So, provided $M_3$ has sufficient space $s'$ and time $t'$, the additional prediction error we get is just $C(M_2,M_3)$, which is typically small for most $M_2,M_3$ we might usually consider using.

Prediction error bound for Bayesian learning on neural networks
===============================================================

Claim 4: We can obtain a similar prediction error bound for Bayesian learning on neural networks 
-------------------------------------------------------------------------------------------------

Now, we will derive a similar style of bound for an inductor using Bayesian learning on neural networks.

### **Setup**

In this setting, our inputs $x$ are finite-dimensional vectors of real numbers $x\in X\subseteq \mathbb{R}^{d_{\text{in}}}$. The labels are still binary, $y\in \{0,1\}$.[^tjrxt18xeea] The inductor now makes its predictions using functions $f(w)$, which take vectors $x_n\in X$ as input and output probabilities for the data labels $y_n$. The functions are all part of some space of functions $f\in\mathcal{F}$. The functions are parametrized by a parameter-function map $\mathcal{M}:\mathbb{R}^D\rightarrow \mathcal{F}$ with $D\in \mathbb{N}$. We call $D$ the number of neural network parameters. We refer to the probabilities the function $f(w)$ outputs for input vector $x_n$ as $f(y_n\mid x_n,w)$. As in the previous sections, we assume that the data labels $y_n$ were generated from the inputs $x_n$ by some probabilistic program $\mu$. Note that we do not make any assumptions about the inputs $x_n$ being drawn IID.

The inductor starts with a uniform prior over some finite hypervolume $W$ in parameter space: $W=(-\frac{L}{2},\frac{L}{2})^D\subset \mathbb{R}^D$. The inductor makes its predictions as 

$$
\begin{equation} P_{f}(y_n\mid x_n, \mathcal{D}_{<n})=\int dw  f(y_n \mid x_n,w) P(w\mid \mathcal{D}_{<n})\,. \end{equation}
$$

 where $P(w\mid \mathcal{D}_{<n})$ is the probability density the inductor places on parameter configuration $w$ after updating on data-label pairs $(x_{1},y_{1},\dots,x_{n-1},y_{n-1})$.

### **Claim**

The total expected prediction error of this induction measured in bits of cross-entropy is upper bounded by 

$$
\begin{equation} \begin{aligned} \sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n),P_{f}(\cdot\mid x_n, \mathcal{D}_{<n}))\leq& C(w^*,\epsilon,f)+N \epsilon\&+\sum^{N}_{n=1}H(P_\mu(\cdot\mid x_n),f(\cdot\mid x_n, w^*))\,, \end{aligned} \tag{2.1}\end{equation}
$$

 for all $N\in\mathbb{N}_{>0}$, all parameter configurations $w^*\in W$, and all $\epsilon\in \mathbb{R}_{\geq0}$. Here, $C(w^*,\epsilon,f)$ is the logarithm of the ratio between the volume of the whole prior $V_W:=\int_W\,dw =L^D$, and the volume taken up by the set $W_{\epsilon,w^*}$ of parameter configurations that are mapped to functions which match the log-probabilities of $f(y_n\mid x_n, w^*)$ up to tolerance $\epsilon$: 

$$
\begin{equation} \begin{aligned} &C(w^*,\epsilon,f):=-\log_2\left(\frac{\int_{W_{\epsilon,w^*}} dw}{V_W}\right)\ &W_{\epsilon,w^*}:=\{w\in W \mid\, \vert\log_2f(y\mid x,w)-\log_2f(y\mid x,w^*)\vert\leq\epsilon\,\,\forall (x,y)\in X\times \{0,1\}\}\ \end{aligned} \end{equation}
$$

 In other words, if there is a parameter configuration $w^*\in(-\frac{L}{2},\frac{L}{2})^D$ that is mapped to a function $f(w^*)$ that is an efficient predictor of the data, in the sense that $f(w^*)$ approximates the probability assignments of $\mu$ up to some error, the inductor will predict the data as well as this efficient predictor $f(w^*)$, plus a tolerance $\epsilon\in\mathbb{R}_{\geq 0}$ we can freely choose, up to an offset equal to the cost in bits of specifying the predictor $f(w^*)$ in the parameter space to $\epsilon$ precision. Intuitively, the reason we don't just always choose $\epsilon=0$ in this bound is that our parameters are real numbers, so describing the location of $f(w^*)$ in parameter space exactly could sometimes take infinitely many bits.

### **High-level proof summary**

The proof works analogously to the proof for the error bound in Equation (1.1), except that sums over programs are replaced by integrals over parameters, and the semimeasure of programs in the prior matching the outputs of efficient predictor $\mu^*$ on all possible input bit strings $x\in\{0,1\}^*$ is replaced by the volume of $W_{\epsilon,w^*}$, the set of parameter configurations matching the log-probabilities output by function $f(w^*)$ to $\epsilon$ precision.

+++ **Proof**

As before, we start by rearranging our expression for the total cross-entropy: 

$$
\begin{equation} \begin{aligned} &\sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n),P_{f}(\cdot\mid x_n, \mathcal{D}_{<n}))\ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\sum^{N}_{n=1}\log_2\left(\int_W dw  f(y_n \mid x_n, w) P(w\mid \mathcal{D}_{<n})\right) \ &=-\sum_{y_N,\dots, y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\frac{1}{V_W}\int_W dw  \prod^N_{n=1}f(y_n \mid x_n, w)\right) \ \end{aligned} \end{equation}
$$

In the second equality, we used the assumption that our inductor adjusts its probabilities over parameter configurations in response to incoming evidence using Bayesian updating.

Now, we restrict the integral $\int_W dw$ to points in $W_{\epsilon,w^*}$, then use the bound $\vert \log_2f(y\mid x,w)-\log_2f(y\mid x,w^*)\vert\leq\epsilon$ we have for points in this set: 

$$
\begin{equation} \begin{aligned} &\sum^{N}_{n=1} H(P_{\mu}(\cdot\mid x_n),P_{f}(\cdot\mid x_n, \mathcal{D}_{<n}))\ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\frac{1}{V_W}\int_W dw  \prod^N_{n=1}f(y_n \mid x_n, w)\right) \ &\leq -\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\frac{1}{V_W}\int_{W_{\epsilon,w^*}} dw \prod^N_{n=1}f(y_n \mid x_n, w)\right)\ &\leq -\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\frac{1}{V_W}\int_{W_{\epsilon,w^*}} dw 2^{\sum^N_{n=1}\log_2(f(y_n \mid x_n, w^*))-N\epsilon}\right)\ &=-\sum_{y_N,\dots,y_1} P_\mu(y_N\mid x_N) \dots P_\mu(y_1\mid x_1)\log_2\left(\frac{\int_{W_{\epsilon,w^*}} dw}{V_W} 2^{\sum^N_{n=1}\log_2(f(y_n \mid x_n, w^*))}2^{-N\epsilon}\right)\ &=-\log_2\left({\frac{\int_{W_{\epsilon,w^*}} dw}{V_W}}\right)+\sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n),f(\cdot\mid x_n, w^*))+N\epsilon\ &=C(w^*,\epsilon,f)+\sum^{N}_{n=1}H(P_{\mu}(\cdot\mid x_n),f(\cdot\mid x_n, w^*))+N\epsilon\ \end{aligned} \end{equation}
$$




+++

### **Comments**

1.  The bound holds for any $w^*\in W$ and any $\epsilon\in\mathbb{R}_{\geq 0}$, though the tightest bound will of course come from the $w^*$ and $\epsilon$ that balance the tradeoff between predictive accuracy and description length best.
2.  The larger $N$ is, the more predictive accuracy matters relative to description length, and the smaller we might want to set $\epsilon$ if we want to obtain the tightest bound.
3.  If we have a more specific question about generalization error, we can get a tighter bound by restricting $W_{\epsilon,w^*}$ to range over a more limited set of possible input/output pairs. For example, if we're confident an image classifier will never receive input images above a certain brightness, we can exclude all images above that brightness level from the set $X$ in the definition of $W_{\epsilon,w^*}$, which might make $C(w^*,\epsilon,f)$ smaller and the upper bound tighter.
4.  This derivation assumes a uniform prior over parameters for simplicity, but it goes through analogously for other priors such as Gaussians.

Relating $C(w^*,\epsilon,f)$ to SLT quantities
----------------------------------------------

$C(w^*,\epsilon,f)$ is a pretty similar quantity to the $\epsilon$-ball that defines the learning coefficient in Singular Learning Theory. There, the prediction error in-distribution includes the logarithm of a term [of the form](https://www.lesswrong.com/s/czrXjvCLsqGepybHC/p/4eZtmwaqhAgdJQDEg)[^5kyn2bf9xq8] 

$$
\begin{equation} \begin{aligned} &V(\epsilon):=\frac{\int_{W_\epsilon} dw}{V_W}\ &W_{\epsilon}:=\{w\in W\mid L(w)<\epsilon\}\ &L(w):= \int dx\, q(x)\sum_y D_{\text{KL}}(P_\mu(y\mid x), f(y\mid x,w)) \end{aligned} \end{equation}
$$

 where $q(x)$ is the 'training distribution' over inputs $x$.

Comparing $-\log_2 V(\epsilon)$ to $C(w^*,\epsilon,f)$:

1.  The uniform distribution over all inputs $x$ over the whole domain $X$ plays the same role for the definition of $C(w^*,\epsilon,f)$ that the ‘training distribution’ does for $V(\epsilon)$.
2.  In $C(w^*,\epsilon,f)$, the outputs $f(y\mid x,w^*)$ of the reference function $f(w^*)$ play the role that the 'data labels' $P_\mu(y\mid x)$ do in $V(\epsilon)$.
3.  $C(w^*,\epsilon,f)$ cares about the *supremum* of divergences over the distribution, $V(\epsilon)$ cares about the *average*. $V(\epsilon)$ is defined as the integral over the set of parameter configurations that diverge from the data labels by less than $\epsilon$ on average over the training data, as scored by KL-divergence, whereas $C(w^*,\epsilon,f)$ is defined as the volume of the set of points that diverge from $f(w^*)$ by epsilon or less on all data points, as scored by log‑probability difference.

These differences are the price of describing prediction error in general instead of 'in-distribution'. In SLT, we assume that our data $x_n$ are drawn IID from some known distribution $q(x)$. In that case, average error over that distribution is enough to bound the inductor's expected average error on future data. Without this assumption of IID sampling, we need to classify functions $f(w)$ based on how closely their outputs align with our reference $f(w^*)$ on *all* possible inputs $x$. Or at least, all inputs $x$ we think the inductor might possibly encounter.

In SLT, $\epsilon$ is also set to $\epsilon\propto\frac{1}{N}$ in the expression for the prediction error instead of being left free as in Equation (2.1), because the theory is primarily concerned with the infinite data limit $N\rightarrow\infty$, where describing the solution to exact precision is 'worth it' and yields a tighter bound. To put that slightly more quantitatively: One term for the prediction error in SLT scales as $N \epsilon$, while $-\log_2V(\epsilon)$ can be shown to only scale as $-\lambda\log_2\epsilon+o(\log_2\epsilon)$[^87apbau753l], where $\lambda$ is a scalar number called the learning coefficient. So, in the vanilla SLT setup, letting $\epsilon$ go to zero for $N\rightarrow\infty$ as $\epsilon\propto\frac{1}{N}$ yields a tighter bound for the prediction error than setting it to some finite non-zero value. But the bound in this post is supposed to work for any amount of data $N$, so we don't set $\epsilon$ to any particular value.

Open problems and questions
===========================

**Section TL;DR:** What kind of neural network architectures have a prior equivalent to that of a bounded universal Turing machine? How can we estimate the description length $C(w^*,\epsilon,f)$ in practice?

How do the priors actually relate to each other?
------------------------------------------------

So, we can sort of think about Bayesian learning on neural networks and compute-bounded Solomonoff induction using a similar set of mathematical tools. But how similar are these induction processes really? That is, how much does a uniform prior over parameter configurations on some neural network architecture resemble a uniform prior over programs on some compute-bounded UTM?

Another way of asking that question is whether we can get something like Equation (1.3) for switching between a bounded UTM and a neural network, and vice versa. So, can we get something like:

**Conjecture 1:** For any parameter vector $w^*$ parametrizing some function $f(w^*)\in \mathcal{F}$, the prediction error of an inductor using bounded UTM $M_2$ is bounded by 

$$
\begin{equation}    \begin{aligned}    \sum^{N}_{n=1} H(P_\mu(\cdot\mid x_n),P_{M_2}(\cdot\mid x_n, \mathcal{D}_{<n}))\leq&  C(w^*,\epsilon,f)+C(f,\tilde\epsilon, M_2)+N (\epsilon+\tilde\epsilon)\    &+\sum^{N}_{n=1}H(P_\mu(\cdot\mid x_n),f(\cdot\mid x_n, w^*))\,,    \end{aligned}    \end{equation}
$$

where $C(f,\tilde\epsilon, M_2)$ is the description length of the neural network architecture $f$ on UTM $M_2$ to precision $\tilde\epsilon$.[^5plp6dm4yrv] Provided $M_2$ has enough time and memory to simulate $f(w^*)$, of course.

**Conjecture 2 (Likely false for arbitrary NN architectures):** For any program $\mu^*$ on bounded UTM $M_2$, the prediction error of an inductor using neural network architecture $f$ is bounded by 

$\begin{equation}\begin{aligned}\sum^{N}_{n=1} H(P_{\mu}(\cdot\mid x_n),P_{f}(\cdot\mid x_n, \mathcal{D}_{<n}))\leq&  C(\mu^*,M_2)+C(M_2,\epsilon,f)+N \epsilon\&+\sum^{N}_{n=1} H\left(P_\mu(\cdot\mid x_n),P_{\mu^*}(\cdot\mid x_n)\right)\,,\end{aligned}\end{equation}$

where $C(M_2, \epsilon, f)$ is the description length in bits of bounded UTM $M_2$ on neural network architecture $f$ to precision $\epsilon$.

If both of these conjectures were true, doing Bayesian learning using neural networks instead of an ensemble of programs would be almost no more of a change than doing Bayesian learning in one programming language instead of another.[^h65uv8rmfm4]

My guess is that something vaguely like Conjecture 1 is true. With sufficient compute, we can use a UTM to simulate any neural network architecture to some arbitrary desired floating point precision. But I think Conjecture 2 is generally false, because not every neural network architecture can simulate a bounded UTM. Remember, our definition of 'neural network' here was basically just 'a space of functions $\mathcal{F}$ parametrized by some parameter-function map $\mathcal{M}:\mathbb{R}^D\rightarrow \mathcal{F}$'. A family of polynomials would satisfy that definition. And I doubt a uniform prior over polynomials acts much like a uniform prior over compute-bounded programs. 

But maybe Conjecture 2 still holds for some more restricted set of neural network architectures? Like, say, architectures capable of simulating a bounded UTM. [RNNs](https://www.sciencedirect.com/science/article/pii/S0022000085710136) and [transformers run in chain-of-thought mode](https://jmlr.org/papers/v22/20-302.html) can do this, for example.[^a1bodi6ynfg] I originally thought that this requirement for the architecture would be sufficient for Conjecture 2 to hold. But proving the conjecture for transformers in chain-of-thought mode turned out to be trickier than I thought.[^ts5ekty7sac] Maybe you just need to be a bit cleverer about how to do the UTM simulation on the transformer than I was so far. Or maybe, being able to simulate a bounded UTM actually isn't a sufficient requirement for Conjecture 2, and the architecture needs to have some additional property. In that case, it'd be interesting to find out what that property is.

What does $C(w^*,\epsilon,f)$ look like in practice?
----------------------------------------------------

For example, does $C(w^*,\epsilon,f)$ behave like $V(\epsilon)$ in vanilla SLT in the limit $\epsilon\rightarrow 0$? That is, for small enough $\epsilon$ and some reasonable conditions on the NN architecture[^dac7yld06oq] do we often get something like 

$$
\begin{equation} C(w^*,\epsilon,f)\propto -\lambda'\log_2\epsilon \end{equation}
$$

 where $\lambda'$ would then be some number analogous to the learning coefficient $\lambda$ in vanilla SLT? Can we use stochastic gradient Langevin dynamics (SGLD) sampling to estimate $C(w^*,\epsilon,f)$ on neural networks in real life, the [same way](https://arxiv.org/abs/2308.12108) people use it to determine the learning coefficient? If a solution can generalize out-of-distribution, it can certainly generalize in-distribution, but the reverse is generally not true. So, presumably $C(w^*,\epsilon,f)$ would be as large as $-\log_2V(\epsilon)$ or larger. But how much larger does it tend to be in practice? In other words, how much does OOD generalization error usually differ from in-distribution generalization error?

Acknowledgments
===============

Thanks to Aram Ebtekar for providing many useful citations. Thanks to Lee Sharkey for helping me come up with a title. Thanks to Cole Wyeth for spotting an unnecessary condition in my original definition of the bounded UTM. And thanks to Aram Ebtekar as well as Mathias Dellago, Alexander Gietelink Oldenziel, Daniel Murfet, David Quarel, Kaarel Hänni, John Wentworth, Dmitry Vaintrob, Jake Mendel, Linda Linsefors, and Scott Aaronson for various discussions and ideas that were causally upstream of my writing this.

[^dajyj8gdh0n]: Though in practice, using the formulas for models trained on finite amounts of data does seem to (maybe?) work alright a lot of the time. In our experience so far at least. Provided we aren't screwing up things without noticing, which tends to happen a lot in research. 

[^83p43t4mm16]: It also does other things, but this is maybe its most famous result, and the one that matters most for this post. 

[^ixa6eerf2w]: I expect that basically nothing in the first part is actually novel, though I haven't managed to track down citations for every result in it in the exact form given here. If you think you know your AIT and don't need to read this part, you might be right. But I'd advise some caution before skipping it. I wrote it partially because many AIT-knowledgeable people I talked to about this topic turned out not to know these things.[19] 

[^zdbrwjjlysa]: As in a program that outputs probabilities as strings. Those probabilities are then used to sample the labels. Note that the program can output probabilities \(1.0\) and \(0\), so the labels \(y_n\) can be deterministic functions of the inputs \(x_n\), they just don't need to be. 

[^5e0ynigxxx]: So, not prefix-free. Lots of standard AIT results assume a prefix-free UTM. This post does not. AIT-savvy skim readers beware. If you compare the theorems here to results phrased for the setting of prefix-free programs, you might become pretty confused. 

[^w0xqpoxf9u]: See e.g. the start of section three here for more on the definition of monotone Turing machines. 

[^turt1epal9]: As in the standard setup for Solomonoff induction with probabilistic programs, \(M_1(p_n)\) can keep running and printing more output digits indefinitely, representing the output probabilities with ever higher precision. 

[^8b582udqgib]: So, if \(\mu\) is deterministic and only outputs probabilities \(0\) or \(1\), this second term will vanish. 

[^xd0gyg0on0i]: See also, for example, theorem 1 this paper, which shows almost the same thing in an RL setting. 

[^9pcfd24lrkg]: See the proof here for example. 

[^tjrxt18xeea]: The derivation should work for other kinds of settings as well though, such as next token prediction in language modelling. I'm just sticking to a specific simple case to make the math easier to follow. 

[^5kyn2bf9xq8]: For the special case of uniform prior, discrete outputs \(y\), and our loss function being cross-entropy error measured in bits. 

[^87apbau753l]: SLT convention usually considers prediction error scored in nats, I'm translating to bits here. 

[^5plp6dm4yrv]: For some to-be-determined definition of 'precision' that makes the conjecture work. Basically, we'd want some measure of the floating‑point precision the UTM uses to approximate the real-number-valued parameters and network inputs. 

[^h65uv8rmfm4]: Still only "almost", because of the extra \(\epsilon\) terms. Those don't show up when converting between UTMs. 

[^a1bodi6ynfg]: The results in those links come with some annoying caveats, so if you want to jump on this you might want to use different constructions to do the UTM emulation. 

[^ts5ekty7sac]: Basically, making unused NN parameters not interfere with the computation no matter what values they're set to is kind of tough. As a consequence, I keep ending up with prefactors \(>1.0\) in front of the \(C(\mu^*,M_2)\) term. 

[^dac7yld06oq]: e.g., analyticity. 

[^a1t5uxn2wwu]: Not judging. I also thought myself somewhat AIT-knowledgeable, but I did not realize some of what it had to say about degeneracy until fairly recently. I spent years being very confused about how learning works because of this.