SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.11678 · ICML · 2022

Bayesian Model Selection, the Marginal Likelihood, and Generalization

Micah Goldblum, Pavel Izmailov, Andrew Wilson, Gregory Benton, Sanae Lotfi

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2202.11678.json · badge: /api/ran/2202.11678.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
sanaelotfi/bayesian_model_comparison canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
FunctionStatusWhere it lives
CondtionalMLL Ran
ran; our contract draft was wrong, not the code
sanaelotfi/bayesian_model_comparison/DKL_experiments/exact_runner.py
code served (permissive licence) · get_code("7ae3dc063aaedd3f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (1, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class DummyGP(nn.Module):
    def __init__(self):
        super().__init__()
        self.feature_extractor = nn.Linear(4, 3)
        self.covar_module = DummyKernel()
        self.likelihood = DummyLikelihood()
    
    def scale_to_bounds(self, x):
        return x

class DummyKernel(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, x1, x2):
        return DummyCovariance(x1, x2)

class DummyCovariance:
    def __init__(self, x1, x2):
        self.x1 = x1
        self.x2 = x2
    
    def evaluate(self):
        batch_size = self.x1.shape[0]
        covar = torch.randn(batch_size, batch_size)
        covar = (covar + covar.T) / 2
        covar += torch.eye(batch_size) * 2
        return covar

class DummyLikelihood:
    def __init__(self):
        self.noise = 0.1

gp = DummyGP()
x = torch.randn(2, 4)
y = torch.randn(2, 1)
xm = torch.randn(2, 4)
ym = torch.randn(2, 1)

ARGS = {
    'gp': gp,
    'x': x,
    'y': y,
    'xm': xm,
    'ym': ym
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (1, 1) — shape (1, 1) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RMSE Ran
ran, honoured the contract we drafted
sanaelotfi/bayesian_model_comparison/DKL_experiments/exact_runner.py
code served (permissive licence) · get_code("93fe84b4567ceb63")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for preds and targets
# The function calls .squeeze().cpu().pow(2).mean().pow(0.5)
# So we need tensors that can be squeezed and operated on
preds = torch.randn(2, 4)
targets = torch.randn(2, 4)

ARGS = {
    "preds": preds,
    "targets": targets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_bma_acc Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sanaelotfi/bayesian_model_comparison/Laplace_experiments/cifar/logcml_cifar100_cnns.py
code served (permissive licence) · get_code("5ea6bb4d9dff8b19")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np
from torch.nn.utils import parameters_to_vector, vector_to_parameters

torch.manual_seed(0)

# Build a minimal neural network
class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(4, 8)
        self.fc2 = nn.Linear(8, 3)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

net = SimpleNet()

# Build a minimal Laplace approximation stand-in
class LaPlaceStandIn:
    def __init__(self, n_params):
        self.n_params = n_params
        self.mean = torch.randn(n_params)
        self.posterior_scale = torch.abs(torch.randn(n_params)) + 0.1
        
        # For kron structure, create a minimal posterior_precision object
        self.posterior_precision = KronPosteriorPrecision(n_params)

class KronPosteriorPrecision:
    def __init__(self, n_params):
        self.n_params = n_params
    
    def bmm(self, samples, exponent=-0.5):
        # Simple stand-in: just apply scaling based on exponent
        if exponent == -0.5:
            return samples * 0.5
        return samples

n_params = sum(p.numel() for p in net.parameters())
la = LaPlaceStandIn(n_params)

# Build a minimal data loader (list of (x, y) tuples)
loader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([2, 0])),
]

ARGS = {
    'net': net,
    'la': la,
    'loader': loader,
    'n_samples': 2,
    'hessian_structure': 'diag',
    'temp': 1.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_ll Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
sanaelotfi/bayesian_model_comparison/Laplace_experiments/cifar/logcml_cifar100_cnns.py
code served (permissive licence) · get_code("6f28b7641dcb5917")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch

torch.manual_seed(0)

# Construct bma_probs: array of probability distributions
# Shape should be (num_samples, num_classes)
num_samples = 2
num_classes = 4
bma_probs = np.random.dirichlet(np.ones(num_classes), size=num_samples).astype(np.float32)

# Construct all_ys: labels corresponding to each sample
# Labels should be valid indices into the probability dimension
all_ys = np.array([0, 2], dtype=np.int64)

ARGS = {
    "bma_probs": bma_probs,
    "all_ys": all_ys,
    "eps": 0.0001
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_mll Ran
ran; our contract draft was wrong, not the code
sanaelotfi/bayesian_model_comparison/DKL_experiments/exact_runner.py
code served (permissive licence) · get_code("d7b8514511255eb4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (1, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
import torch.nn as nn
from gpytorch.models import ExactGP
from gpytorch.means import ConstantMean
from gpytorch.kernels import ScaleKernel, RBFKernel
from gpytorch.likelihoods import GaussianLikelihood
from gpytorch.distributions import MultivariateNormal

torch.manual_seed(0)

class SimpleFeatureExtractor(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(3, 4)
    
    def forward(self, x):
        return self.linear(x)

class SimpleBounds(nn.Module):
    def forward(self, x):
        return x

class SimpleGP(nn.Module):
    def __init__(self):
        super().__init__()
        self.feature_extractor = SimpleFeatureExtractor()
        self.scale_to_bounds = SimpleBounds()
        self.covar_module = ScaleKernel(RBFKernel())
        self.likelihood = GaussianLikelihood()
        self.likelihood.noise = torch.tensor(0.1)
    
    def forward(self, x):
        x = self.feature_extractor(x)
        x = self.scale_to_bounds(x)
        return x

gp = SimpleGP()

x = torch.randn(2, 3)
y = torch.randn(2, 1)

ARGS = {
    "gp": gp,
    "x": x,
    "y": y
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
gpytorch, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (1, 1) — shape (1, 1) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

How do we compare between hypotheses that are entirely consistent with observations? The marginal likelihood (aka Bayesian evidence), which represents the probability of generating our observations from a prior, provides a distinctive approach to this foundational question, automatically encoding Occam's razor. Although it has been observed that the marginal likelihood can overfit and is sensitive to prior assumptions, its limitations for hyperparameter learning and discrete model comparison have not been thoroughly investigated. We first revisit the appealing properties of the marginal likelihood for learning constraints and hypothesis testing. We then highlight the conceptual and practical issues in using the marginal likelihood as a proxy for generalization. Namely, we show how marginal likelihood can be negatively correlated with generalization, with implications for neural architecture search, and can lead to both underfitting and overfitting in hyperparameter learning. We also re-examine the connection between the marginal likelihood and PAC-Bayes bounds and use this connection to further elucidate the shortcomings of the marginal likelihood for model selection. We provide a partial remedy through a conditional marginal likelihood, which we show is more aligned with generalization, and practically valuable for large-scale hyperparameter learning, such as in deep kernel learning.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2202.11678")
get_code_for_paper("2202.11678")
have("2202.11678")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2202.11678.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2202.11678.svg)](https://syntology.ai/paper/2202.11678)

Connect an agent — have() is free.