SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.18205 · NeurIPS · 2024

Bridging OOD Detection and Generalization: A Graph-Theoretic View

Yixuan Li, Han Wang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 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; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2409.18205.json · badge: /api/ran/2409.18205.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
deeplearning-wisc/graph-spectral-ood canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
ODIN Ran
ran; our contract draft was wrong, not the code
deeplearning-wisc/graph-spectral-ood/utils/score_calculation.py
code served (permissive licence) · get_code("17bbd961aaf86569")
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 ndarray, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. 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, 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
from torch.autograd import Variable
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Build a minimal model that takes input and produces outputs
class SimpleModel(nn.Module):
    def __init__(self, input_dim, num_classes):
        super(SimpleModel, self).__init__()
        self.fc = nn.Linear(input_dim, num_classes)
    
    def forward(self, x):
        return self.fc(x)

# Create model
model = SimpleModel(input_dim=4, num_classes=3)

# Create input tensor with requires_grad=True for backward pass
batch_size = 2
input_dim = 4
num_classes = 3
inputs = Variable(torch.randn(batch_size, input_dim), requires_grad=True)

# Create outputs from model
outputs = model(inputs)

# Parameters for ODIN function
temper = 1.0
noiseMagnitude1 = 0.1

ARGS = {
    "inputs": inputs,
    "outputs": outputs,
    "model": model,
    "temper": temper,
    "noiseMagnitude1": noiseMagnitude1
}
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 ndarray, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) 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_Mahalanobis_score Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
deeplearning-wisc/graph-spectral-ood/utils/score_calculation.py
code served (permissive licence) · get_code("24f5b40495bb542e")
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 ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. 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, 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
from torch.utils.data import DataLoader, TensorDataset

torch.manual_seed(0)

# Create a small model with intermediate_forward method
class SimpleModel(nn.Module):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.conv1 = nn.Conv2d(3, 8, kernel_size=3, padding=1)
        self.conv2 = nn.Conv2d(8, 16, kernel_size=3, padding=1)
        self.fc = nn.Linear(16 * 4 * 4, 10)
    
    def intermediate_forward(self, x, layer_index):
        if layer_index == 0:
            x = self.conv1(x)
            return x
        elif layer_index == 1:
            x = self.conv1(x)
            x = self.conv2(x)
            return x
        else:
            x = self.conv1(x)
            x = self.conv2(x)
            x = x.view(x.size(0), -1)
            return x
    
    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x

model = SimpleModel()

# Create a small test loader (batch_size=2, 3-channel images 4x4)
data = torch.randn(4, 3, 4, 4)
targets = torch.tensor([0, 1, 0, 1])
dataset = TensorDataset(data, targets)
test_loader = DataLoader(dataset, batch_size=2, shuffle=False)

# Number of classes
num_classes = 2

# Create sample means for each layer
# Layer 0 output: (batch=2, channels=8) -> after view and mean: (2, 8)
# Layer 1 output: (batch=2, channels=16) -> after view and mean: (2, 16)
layer_index = 1
feature_dim = 16

sample_mean = {}
sample_mean[0] = torch.randn(num_classes, 8)
sample_mean[1] = torch.randn(num_classes, feature_dim)

# Create precision matrices (inverse covariance)
precision = {}
precision[0] = torch.randn(8, 8)
precision[1] = torch.randn(feature_dim, feature_dim)

# Other parameters
magnitude = 0.002
num_batches = 2
in_dist = False

ARGS = {
    'model': model,
    'test_loader': test_loader,
    'num_classes': num_classes,
    'sample_mean': sample_mean,
    'precision': precision,
    'layer_index': layer_index,
    'magnitude': magnitude,
    'num_batches': num_batches,
    'in_dist': in_dist
}
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 ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) 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_ood_scores_odin Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
deeplearning-wisc/graph-spectral-ood/utils/score_calculation.py
code served (permissive licence) · get_code("3ad01de2f86dccba")
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 ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. 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, 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)

# Create a simple model
class SimpleNet(nn.Module):
    def __init__(self):
        super(SimpleNet, self).__init__()
        self.fc = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.fc(x)

# Create model instance
net = SimpleNet()
net.eval()

# Create a simple data loader (list of batches)
# Each batch is (data, target)
data1 = torch.randn(2, 4)
target1 = torch.tensor([0, 1])
data2 = torch.randn(2, 4)
target2 = torch.tensor([2, 0])
loader = [(data1, target1), (data2, target2)]

# Define parameters
bs = 2  # batch size
ood_num_examples = 4
T = 1.0  # temperature
noise = 0.1  # noise magnitude
in_dist = False

ARGS = {
    'loader': loader,
    'net': net,
    'bs': bs,
    'ood_num_examples': ood_num_examples,
    'T': T,
    'noise': noise,
    'in_dist': in_dist
}
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 ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) 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
load_CorCifar Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
deeplearning-wisc/graph-spectral-ood/CIFAR/make_datasets.py
code served (permissive licence) · get_code("00b7465723fc955d")
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. 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
from pathlib import Path
from unittest.mock import Mock, MagicMock

torch.manual_seed(0)

# Create mock Dataset class that will be imported
class CorCIFARDataset:
    def __init__(self, split, cortype, data_path):
        self.split = split
        self.cortype = cortype
        self.data_path = data_path
        self.data = [(torch.randn(3, 32, 32), i % 10) for i in range(2)]
    
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        return self.data[idx]

# Mock the dataloader module
import sys
from types import ModuleType

dataloader_module = ModuleType('dataloader')
corcifar10_module = ModuleType('corcifar10Loader')
corcifar10_module.CorCIFARDataset = CorCIFARDataset
dataloader_module.corcifar10Loader = corcifar10_module
sys.modules['dataloader'] = dataloader_module
sys.modules['dataloader.corcifar10Loader'] = corcifar10_module

# Define ARGS
ARGS = {
    'dataset': 'train',
    'cortype': 'gaussian_blur'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
dataloader, 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
normalized_thresh Ran
ran; our contract draft was wrong, not the code
deeplearning-wisc/graph-spectral-ood/CIFAR/models/wrn.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from deeplearning-wisc/sorl, is pointer only (licence: NONE) · get_code("b645d731bc4d2de3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from deeplearning-wisc/sorl, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

unpickle Ran
ran; our contract draft was wrong, not the code
deeplearning-wisc/graph-spectral-ood/utils/imagenet_rc_loader.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from haiyunyao/diversemix, is pointer only (licence: NONE) · get_code("4ebc0e09cb353eac")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from haiyunyao/diversemix, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_CIFAR Not yet run
unverified (harvested, no recorded run)
deeplearning-wisc/graph-spectral-ood/CIFAR/make_datasets.py
code served (permissive licence) · get_code("2b388cb209f9ada4")
How it ran

no invocation recorded.

load_CorImageNet Not yet run
unverified (harvested, no recorded run)
deeplearning-wisc/graph-spectral-ood/CIFAR/make_datasets.py
code served (permissive licence) · get_code("c63450f1ff9c5044")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 1 later) and 3 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
unpickle 7 other papers
6 dated earlier, 1 later
1911.07205 (2019-11)
REFIT: A Unified Watermark Removal Framework For Deep Learning Systems With Limited Data
2104.08984 (2021-04)
Contrastive Learning Improves Model Robustness Under Label Noise
2202.03299 (2022-02)
Training OOD Detectors in their Natural Habitats
and 4 more not named here
ODIN 3 other papers
3 dated earlier
aaai_20752 (2022 (year only))
Provable Guarantees for Understanding Out-of-Distribution Detection
2202.01197 (2022-02)
VOS: Learning What You Don't Know by Virtual Outlier Synthesis
2202.03299 (2022-02)
Training OOD Detectors in their Natural Habitats
get_ood_scores_odin 3 other papers
3 dated earlier
aaai_20752 (2022 (year only))
Provable Guarantees for Understanding Out-of-Distribution Detection
2202.01197 (2022-02)
VOS: Learning What You Don't Know by Virtual Outlier Synthesis
2202.03299 (2022-02)
Training OOD Detectors in their Natural Habitats
normalized_thresh 3 other papers
3 dated earlier · 1 only as an assembly brick
2308.05017 (2023-08)
When and How Does Known Class Help Discover Unknown Ones? Provable Understanding Through Spectral Analysis
2311.03524 (2023-11)
A Graph-Theoretic Framework for Understanding Open-World Semi-Supervised Learning
2405.18635 (2024-05)
When and How Does In-Distribution Label Help Out-of-Distribution Detection?
get_Mahalanobis_score 2 other papers
2 dated earlier
2202.01197 (2022-02)
VOS: Learning What You Don't Know by Virtual Outlier Synthesis
2202.03299 (2022-02)
Training OOD Detectors in their Natural Habitats

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

In the context of modern machine learning, models deployed in real-world scenarios often encounter diverse data shifts like covariate and semantic shifts, leading to challenges in both out-of-distribution (OOD) generalization and detection. Despite considerable attention to these issues separately, a unified framework for theoretical understanding and practical usage is lacking. To bridge the gap, we introduce a graph-theoretic framework to jointly tackle both OOD generalization and detection problems. By leveraging the graph formulation, data representations are obtained through the factorization of the graph's adjacency matrix, enabling us to derive provable error quantifying OOD generalization and detection performance. Empirical results showcase competitive performance in comparison to existing methods, thereby validating our theoretical underpinnings. Code is publicly available at https://github.com/deeplearning-wisc/graph-spectral-ood.

For agents

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

get_harvested_code_for_paper("2409.18205")
get_code_for_paper("2409.18205")
have("2409.18205")

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

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

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

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

Connect an agent — have() is free.