SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.11905 · NeurIPS · 2021

Dangers of Bayesian Model Averaging under Covariate Shift

Pavel Izmailov, Sanae Lotfi, Andrew Gordon, Wilson Nyu, Patrick Nicholson

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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 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/2106.11905.json · badge: /api/ran/2106.11905.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
izmailovpavel/bnn_covariate_shift canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
google-research/google-research unrelated (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
get_kinetic_energy_diff Ran
ran, honoured the contract we drafted
izmailovpavel/bnn_covariate_shift/bnn_hmc/core/hmc.py
code served (permissive licence) · get_code("9e184ccfacbc9e0b")
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) and returned ArrayImpl, 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 jax
import jax.numpy as jnp

# The function expects two arguments that are pytree structures containing momentum arrays
# It uses jax.tree_util.tree_leaves to flatten them and computes kinetic energy differences

# Create two momentum pytrees - can be nested dicts/lists of arrays
momentum1 = {
    'layer1': jnp.array([[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]),
    'layer2': jnp.array([[0.5, 1.5, 2.5, 3.5]])
}

momentum2 = {
    'layer1': jnp.array([[0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.7, 0.8]]),
    'layer2': jnp.array([[0.05, 0.15, 0.25, 0.35]])
}

ARGS = {
    'momentum1': momentum1,
    'momentum2': momentum2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, 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
make_accept_prob Ran
ran; our contract draft was wrong, not the code
izmailovpavel/bnn_covariate_shift/bnn_hmc/core/hmc.py
code served (permissive licence) · get_code("dfcc30d93baf6385")
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) and returned function. The image it ran in was 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 jax
import jax.numpy as jnp

# Define a simple log_prior_diff_fn that takes two parameter sets and returns a scalar
def log_prior_diff_fn(params1, params2):
    """
    Computes the difference in log prior between two parameter sets.
    params1 and params2 are pytrees (dicts of arrays in this case).
    """
    diff = 0.0
    for key in params1:
        diff += jnp.sum(params1[key] ** 2 - params2[key] ** 2)
    return diff

# Create sample momentum pytrees (list of arrays)
momentum1 = [jnp.array([1.0, 2.0, 3.0, 4.0]), jnp.array([0.5, 1.5])]
momentum2 = [jnp.array([0.8, 1.9, 2.8, 3.9]), jnp.array([0.4, 1.4])]

# Create sample parameter pytrees (dicts of arrays)
params1 = {
    'w1': jnp.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]),
    'b1': jnp.array([0.1, 0.2, 0.3])
}
params2 = {
    'w1': jnp.array([[0.9, 1.9, 2.9], [3.9, 4.9, 5.9], [6.9, 7.9, 8.9], [9.9, 10.9, 11.9]]),
    'b1': jnp.array([0.05, 0.15, 0.25])
}

# Create sample log-likelihood values
log_likelihood1 = jnp.array(-2.5)
log_likelihood2 = jnp.array(-2.3)

ARGS = {
    'log_prior_diff_fn': log_prior_diff_fn
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
make_leapfrog Ran
ran; our contract draft was wrong, not the code
izmailovpavel/bnn_covariate_shift/bnn_hmc/core/hmc.py
code served (permissive licence) · get_code("9be31c26360e4981")
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) and returned function. The image it ran in was 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 jax
import jax.numpy as jnp
import numpy as np

# Define a simple log_prob_and_grad function that matches the expected signature
def make_log_prob_and_grad():
    def log_prob_and_grad(dataset, params, net_state):
        # Simulate computing log probability and gradient
        # Returns: (log_prob, grad, log_likelihood, net_state)
        
        # Create dummy gradients matching params structure
        grad = jax.tree_util.tree_map(lambda p: jnp.ones_like(p), params)
        
        log_prob = jnp.array(1.5)
        log_likelihood = jnp.array(0.8)
        
        # net_state is returned unchanged
        return log_prob, grad, log_likelihood, net_state
    
    return log_prob_and_grad

# Create sample data
dataset = jnp.ones((2, 4))  # batch_size=2, feature_dim=4

# Create initial parameters as a nested structure
init_params = {
    'layer1': jnp.ones((4, 3)),
    'layer2': jnp.ones((3, 2))
}

# Create initial network state
init_net_state = {
    'batch_norm_mean': jnp.zeros((3,)),
    'batch_norm_var': jnp.ones((3,))
}

# Create initial momentum matching params structure
init_momentum = jax.tree_util.tree_map(lambda p: jnp.zeros_like(p), init_params)

# Create initial gradient matching params structure
init_grad = jax.tree_util.tree_map(lambda p: jnp.ones_like(p) * 0.1, init_params)

# Set hyperparameters
step_size = 0.01
n_leapfrog = 5

# Create the log_prob_and_grad function
log_prob_and_grad = make_log_prob_and_grad()

ARGS = {
    'log_prob_and_grad': log_prob_and_grad
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
make_student_t_log_prior Ran
ran; our contract draft was wrong, not the code
izmailovpavel/bnn_covariate_shift/bnn_hmc/utils/losses.py
code served (permissive licence) · get_code("6feadab44591aaef")
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) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 jax
import jax.numpy as jnp

# The function takes three scalar parameters
weight_decay = 0.01
degrees_of_freedom = 5.0
temperature = 1.0

ARGS = {
    "weight_decay": weight_decay,
    "degrees_of_freedom": degrees_of_freedom,
    "temperature": temperature,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
uniform Ran
ran, honoured the contract we drafted
google-research/google-research/mir_uai24/priors.py
code served (permissive licence) · get_code("d942f42494790446")
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) and returned ndarray, ndim 2, dtype family float, shape (5, 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 numpy as np

class Instance:
    def __init__(self, bag_id_x_instance_id):
        self.bag_id_x_instance_id = bag_id_x_instance_id

class Memberships:
    def __init__(self, bags):
        self.bags = bags

class DatasetInfo:
    def __init__(self, n_instances, memberships):
        self.n_instances = n_instances
        self.memberships = memberships

# Create a small dataset with 5 instances distributed across 2 bags
# Bag 0: instances [0, 1, 2] (size 3)
# Bag 1: instances [3, 4] (size 2)
bags = {
    0: [Instance(0), Instance(1), Instance(2)],
    1: [Instance(3), Instance(4)]
}

memberships = Memberships(bags)
dataset_info = DatasetInfo(n_instances=5, memberships=memberships)

ARGS = {
    "dataset_info": dataset_info
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (5, 1) — shape (5, 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, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 2 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.

FunctionAlso present inEarliest-datedOthers named
get_kinetic_energy_diff 1 other paper
1 dated earlier
2104.14421 (2021-04)
What Are Bayesian Neural Network Posteriors Really Like?
make_accept_prob 1 other paper
1 dated earlier
2104.14421 (2021-04)
What Are Bayesian Neural Network Posteriors Really Like?
make_leapfrog 1 other paper
1 dated earlier
2104.14421 (2021-04)
What Are Bayesian Neural Network Posteriors Really Like?

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

Approximate Bayesian inference for neural networks is considered a robust alternative to standard training, often providing good performance on out-of-distribution data. However, Bayesian neural networks (BNNs) with high-fidelity approximate inference via full-batch Hamiltonian Monte Carlo achieve poor generalization under covariate shift, even underperforming classical estimation. We explain this surprising result, showing how a Bayesian model average can in fact be problematic under covariate shift, particularly in cases where linear dependencies in the input features cause a lack of posterior contraction. We additionally show why the same issue does not affect many approximate inference procedures, or classical maximum a-posteriori (MAP) training. Finally, we propose novel priors that improve the robustness of BNNs to many sources of covariate shift.

For agents

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

get_harvested_code_for_paper("2106.11905")
get_code_for_paper("2106.11905")
have("2106.11905")

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

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

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

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

Connect an agent — have() is free.