SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.10860 · ICCV · 2021

Tune it the Right Way: Unsupervised Validation of Domain Adaptation via Soft Neighborhood Density

Kate Saenko, Trevor Darrell, Piotr Teterwak, Donghyun Kim, Kuniaki Saito, Stan Sclaroff

arXiv · PDF · Open in the Atlas

Code that ran

4 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, 1 violated it and 0 have no contract verdict; 1 failure of our instrument; 1 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/2108.10860.json · badge: /api/ran/2108.10860.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
kevinmusgrave/pytorch-adapt community
Papers with Code archive
3 ran · 1 no recorded run
visionlearninggroup/snd marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
_mmd_quadratic Ran
ran; our contract draft was wrong, not the code
kevinmusgrave/pytorch-adapt/src/pytorch_adapt/layers/utils.py
code served (permissive licence) · get_code("94f8fc01101d529d")
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 (2, 4) 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)

# Analyze the function:
# - x: tensor that gets unsqueezed at dim 2, then multiplied by scale
# - scale: scalar or tensor that multiplies x
# - weights: tensor that gets multiplied element-wise with exp result, summed over dim 2
# 
# x.unsqueeze(2) adds a dimension at position 2
# If x is shape (batch, dim), unsqueeze(2) makes it (batch, dim, 1)
# Then x.unsqueeze(2) * scale broadcasts
# Result multiplies with weights and sums over dim 2
# weights should have compatible shape for broadcasting and summing over dim 2

# Let's create:
# x: (2, 4) - batch of 2, 4 dimensions
x = torch.randn(2, 4)

# scale: scalar to multiply the exponential argument
scale = torch.tensor(0.5)

# weights: should be broadcastable with exp(x.unsqueeze(2) * scale)
# x.unsqueeze(2) is (2, 4, 1)
# x.unsqueeze(2) * scale is (2, 4, 1)
# weights should be (2, 4, 3) so sum over dim 2 gives (2, 4)
# or could be (1, 4, 3) or (2, 1, 3) etc. Let's use (2, 4, 3)
weights = torch.randn(2, 4, 3)

ARGS = {
    "x": x,
    "scale": scale,
    "weights": 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 2, dtype family float, shape (2, 4) — shape (2, 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_default_kernel_weights Ran
ran, violated the contract we drafted
kevinmusgrave/pytorch-adapt/src/pytorch_adapt/layers/utils.py
code served (permissive licence) · get_code("cf0373553cc13a09")
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 1, dtype family float, shape (5,) 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)

# Test case 1: tensor with multiple elements
scale_multi = torch.randn(5)

# Test case 2: tensor with single element
scale_single = torch.tensor([3.0])

# Test case 3: scalar (non-tensor)
scale_scalar = 2.5

# Create ARGS dict with a multi-element tensor
ARGS = {
    "scale": scale_multi
}
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 1, dtype family float, shape (5,) — shape (5,) 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_weight Ran
ran, honoured the contract we drafted
visionlearninggroup/snd/nc_ps/utils/dev.py
code served (permissive licence) · get_code("290d39bd082c87ea")
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 (50, 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

# Set random seed for reproducibility
np.random.seed(0)

# Create small feature arrays with distinct dimensions
# source_feature: shape [N_tr, d] - training set features
source_feature = np.random.randn(100, 8).astype(np.float32)

# target_feature: shape [N_te, d] - test set features
target_feature = np.random.randn(80, 8).astype(np.float32)

# validation_feature: shape [N_v, d] - validation set features
validation_feature = np.random.randn(50, 8).astype(np.float32)

ARGS = {
    'source_feature': source_feature,
    'target_feature': target_feature,
    'validation_feature': validation_feature
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, sklearn — 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 (50, 1) — shape (50, 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
num_elements_minus_diag Ran
ran, honoured the contract we drafted
kevinmusgrave/pytorch-adapt/src/pytorch_adapt/layers/utils.py
code served (permissive licence) · get_code("5e23c9898c9dacf4")
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 int, ndim 0, dtype family int, 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 numpy as np

torch.manual_seed(0)

# The function num_elements_minus_diag takes a parameter x
# and accesses x.shape[0] to get the first dimension.
# It computes n * (n - 1) where n is that first dimension.
# So x needs to be something with a .shape attribute.

# Create a tensor with shape (4, 3) - small, distinct dimensions
x = torch.randn(4, 3)

ARGS = {
    "x": x
}
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 int, ndim 0, dtype family int, 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_mmd_quadratic Not yet run
unverified (harvested, no recorded run)
kevinmusgrave/pytorch-adapt/src/pytorch_adapt/layers/utils.py
code served (permissive licence) · get_code("7fa7545c81625d00")
How it ran

no invocation recorded.

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

Unsupervised domain adaptation (UDA) methods can dramatically improve generalization on unlabeled target domains. However, optimal hyper-parameter selection is critical to achieving high accuracy and avoiding negative transfer. Supervised hyper-parameter validation is not possible without labeled target data, which raises the question: How can we validate unsupervised adaptation techniques in a realistic way? We first empirically analyze existing criteria and demonstrate that they are not very effective for tuning hyper-parameters. Intuitively, a welltrained source classifier should embed target samples of the same class nearby, forming dense neighborhoods in feature space. Based on this assumption, we propose a novel unsupervised validation criterion that measures the density of soft neighborhoods by computing the entropy of the similarity distribution between points. Our criterion is simpler than competing validation methods, yet more effective; it can tune hyper-parameters and the number of training iterations in both image classification and semantic segmentation models. The code used for the paper will be available at https://github.com/ VisionLearningGroup/SND.

For agents

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

get_harvested_code_for_paper("2108.10860")
get_code_for_paper("2108.10860")
have("2108.10860")

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

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

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

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

Connect an agent — have() is free.