SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.01742 · 2022

CADet: Fully Self-Supervised Out-Of-Distribution Detection With Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

8 of 10 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, 1 violated it and 1 has no contract verdict; 4 failures of our instrument; 2 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/2210.01742.json · badge: /api/ran/2210.01742.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
charlesge/openood-cadet canonical (classifier label)
classifier basis not recorded on the link
8 ran · 2 no recorded run
FunctionStatusWhere it lives
Discriminator32 Ran
ran on a synthesized input
charlesge/openood-cadet/openood/networks/arpl_net.py
code served (permissive licence) · get_code("3cce4936256bdc33")
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 _netD32. 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

torch.manual_seed(0)

ARGS = {
    "n_gpu": 1,
    "nc": 3,
    "ndf": 64
}
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 _netD32 — a _netD32 output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _netD32 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
Generator Ran
ran; our contract draft was wrong, not the code
charlesge/openood-cadet/openood/networks/arpl_net.py
code served (permissive licence) · get_code("797cd0913159403b")
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 _netG. 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

torch.manual_seed(0)

ARGS = {
    "n_gpu": 1,
    "nz": 100,
    "ngf": 64,
    "nc": 3,
}
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 _netG — a _netG output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _netG 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
Generator32 Ran
ran; our contract draft was wrong, not the code
charlesge/openood-cadet/openood/networks/arpl_net.py
code served (permissive licence) · get_code("893f424fd19a9b6c")
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 _netG32. 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

torch.manual_seed(0)

ARGS = {
    "n_gpu": 1,
    "nz": 100,
    "ngf": 64,
    "nc": 3
}
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 _netG32 — a _netG32 output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _netG32 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
create_window Ran
ran, honoured the contract we drafted
charlesge/openood-cadet/openood/losses/ssim.py
pointer only (licence: MIT); the stored copy get_code serves, from Meiqi-Gong/TemCoCo, is pointer only (licence: NONE) · get_code("45b6edb2cf78cda2")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Meiqi-Gong/TemCoCo, 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.

gaussian Ran
ran, honoured the contract we drafted
charlesge/openood-cadet/openood/losses/ssim.py
pointer only (licence: MIT); the stored copy get_code serves, from JS-CHU/RoamScene3D, is pointer only (licence: NONE) · get_code("e2424ce033ba3a0f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from JS-CHU/RoamScene3D, 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.

rew_ce Ran
ran, violated the contract we drafted
charlesge/openood-cadet/openood/losses/reweight.py
code served (permissive licence) · get_code("d8339d591bbd7f52")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Create valid arguments for rew_ce function
batch_size = 2
num_classes = 4

# logits: shape (batch_size, num_classes)
logits = torch.randn(batch_size, num_classes)

# labels: shape (batch_size,) with class indices
labels = torch.tensor([0, 2], dtype=torch.long)

# sample_weights: shape (batch_size,) with positive weights
sample_weights = torch.tensor([1.0, 0.5], dtype=torch.float32)

ARGS = {
    'logits': logits,
    'labels': labels,
    'sample_weights': sample_weights
}
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
soft_cross_entropy Ran
ran; our contract draft was wrong, not the code
charlesge/openood-cadet/openood/losses/sce.py
code served (permissive licence) · get_code("61492b343324d2ea")
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 testing
# logit: shape (batch_size, num_classes) - raw model outputs
# label: shape (batch_size, num_classes) - soft labels (probabilities)
batch_size = 2
num_classes = 4

logit = torch.randn(batch_size, num_classes, requires_grad=True)
label = torch.rand(batch_size, num_classes)
label = label / label.sum(dim=1, keepdim=True)  # normalize to probabilities

# weight: optional class weights
weight = torch.tensor([0.5, 1.0, 1.5, 2.0], requires_grad=False)

ARGS = {
    'logit': logit,
    'label': label,
    'weight': weight,
    'reduce': None,
    'reduction': 'mean'
}
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
ssim Ran
ran; our contract draft was wrong, not the code
charlesge/openood-cadet/openood/losses/ssim.py
code served (permissive licence) · get_code("d1619ad1bb7ea0f7")
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 math import exp
import torch.nn.functional as F

torch.manual_seed(0)

# Create small test images: batch_size=2, channels=3, height=4, width=4
img1 = torch.randn(2, 3, 4, 4)
img2 = torch.randn(2, 3, 4, 4)

# Scale to [0, 255] range to match typical image values
img1 = (img1 - img1.min()) / (img1.max() - img1.min()) * 255
img2 = (img2 - img2.min()) / (img2.max() - img2.min()) * 255

# Create a pre-computed window (optional parameter)
window_size = 11
channel = 3

def gaussian(window_size, sigma):
    gauss = torch.Tensor([exp(-(x - window_size // 2) ** 2 / float(2 * sigma ** 2)) for x in range(window_size)])
    return gauss / gauss.sum()

def create_window(window_size, channel=1):
    _1D_window = gaussian(window_size, 1.5).unsqueeze(1)
    _2D_window = _1D_window.mm(_1D_window.t()).float().unsqueeze(0).unsqueeze(0)
    window = _2D_window.expand(channel, 1, window_size, window_size).contiguous()
    return window

window = create_window(window_size, channel=channel)

ARGS = {
    'img1': img1,
    'img2': img2,
    'window_size': 11,
    'window': window,
    'size_average': True,
    'full': False,
    'val_range': None,
}
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 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
loss_function Not yet run
unverified (harvested, no recorded run)
charlesge/openood-cadet/openood/losses/rd4ad_loss.py
code served (permissive licence) · get_code("4c1d0e3674921db5")
How it ran

no invocation recorded.

rew_sce Not yet run
unverified (harvested, no recorded run)
charlesge/openood-cadet/openood/losses/reweight.py
code served (permissive licence) · get_code("e1014da2309b3946")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 10 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 10 the same month, 10 later) and 0 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
gaussian 160 other papers
28 dated earlier, 2 the same month, 129 later, 1 same year, order not determinable · 7 only as an assembly brick
1812.11941 (2018-12)
High Quality Monocular Depth Estimation via Transfer Learning
1904.01538 (2019-04)
Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset
1907.11628 (2019-07)
Unsupervised Learning for Optical Flow Estimation Using Pyramid Convolution LSTM
and 157 more not named here
create_window 19 other papers
5 dated earlier, 1 the same month, 12 later, 1 same year, order not determinable
1812.11941 (2018-12)
High Quality Monocular Depth Estimation via Transfer Learning
Zavrtanik_DRAEM_-_A_Discriminatively_Trained_Reconstruction_Embedding_for_Surface_Anomaly_ICCV_2021_paper (2021 (year only))
DRAEM -A discriminatively trained reconstruction embedding for surface anomaly detection
2108.07610 (2021-08)
DRAEM -- A discriminatively trained reconstruction embedding for surface anomaly detection
and 16 more not named here
rew_ce 8 other papers
1 dated earlier, 1 the same month, 6 later
2108.11941 (2021-08)
Semantically Coherent Out-of-Distribution Detection
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 5 more not named here
rew_sce 8 other papers
1 dated earlier, 1 the same month, 6 later
2108.11941 (2021-08)
Semantically Coherent Out-of-Distribution Detection
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 5 more not named here
loss_function 7 other papers
1 the same month, 6 later
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
2404.01775 (2024-04)
A noisy elephant in the room: Is your out-of-distribution detector robust to label noise?
and 4 more not named here
soft_cross_entropy 7 other papers
1 dated earlier, 1 the same month, 5 later
2108.11941 (2021-08)
Semantically Coherent Out-of-Distribution Detection
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 4 more not named here
ssim 6 other papers
1 the same month, 5 later
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
2407.08966 (2024-07)
LAPT: Label-driven Automated Prompt Tuning for OOD Detection with Vision-Language Models
and 3 more not named here
Discriminator32 5 other papers
1 dated earlier, 1 the same month, 3 later
2110.06207 (2021-10)
Open-Set Recognition: A Good Closed-Set Classifier is All You Need
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 2 more not named here
Generator 5 other papers
1 dated earlier, 1 the same month, 3 later
2110.06207 (2021-10)
Open-Set Recognition: A Good Closed-Set Classifier is All You Need
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 2 more not named here
Generator32 5 other papers
1 dated earlier, 1 the same month, 3 later
2110.06207 (2021-10)
Open-Set Recognition: A Good Closed-Set Classifier is All You Need
2210.07242 (2022-10)
OpenOOD: Benchmarking Generalized Out-of-Distribution Detection
2303.14531 (2023-03)
SIO: Synthetic In-Distribution Data Benefits Out-of-Distribution Detection
and 2 more not named here

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

Handling out-of-distribution (OOD) samples has become a major stake in the real-world deployment of machine learning systems. This work explores the use of self-supervised contrastive learning to the simultaneous detection of two types of OOD samples: unseen classes and adversarial perturbations. First, we pair self-supervised contrastive learning with the maximum mean discrepancy (MMD) two-sample test. This approach enables us to robustly test whether two independent sets of samples originate from the same distribution, and we demonstrate its effectiveness by discriminating between CIFAR-10 and CIFAR-10.1 with higher confidence than previous work. Motivated by this success, we introduce CADet (Contrastive Anomaly Detection), a novel method for OOD detection of single samples. CADet draws inspiration from MMD, but leverages the similarity between contrastive transformations of a same sample. CADet outperforms existing adversarial detection methods in identifying adversarially perturbed samples on ImageNet and achieves comparable performance to unseen label detection methods on two challenging benchmarks: ImageNet-O and iNaturalist. Significantly, CADet is fully self-supervised and requires neither labels for in-distribution samples nor access to OOD examples.

For agents

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

get_harvested_code_for_paper("2210.01742")
get_code_for_paper("2210.01742")
have("2210.01742")

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

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

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

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

Connect an agent — have() is free.