SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2006.04662 · NeurIPS · 2020

Rethinking Importance Weighting for Deep Learning under Distribution Shift

Masashi Sugiyama, Gang Niu, Tongtong Fang, Nan Lu

arXiv · PDF · Open in the Atlas

Code that ran

4 of 12 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 1 failure of our instrument; 8 no recorded run), measured 2026-11-21; 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/2006.04662.json · badge: /api/ran/2006.04662.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
TongtongFANG/DIW marked official in Papers with Code
Papers with Code archive
3 ran · 8 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
get_int Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from Newbeeer/L_DMI
pointer only; the stored copy get_code serves, from Newbeeer/L_DMI, is pointer only (licence: NONE) · get_code("dc221e9b2bf38877")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

read_image_file Ran
ran, honoured the contract we drafted
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("96b46f91d8c488e9")
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 Tensor, ndim 3, dtype family int, shape (2, 4, 3) 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
import struct
import tempfile
import os

torch.manual_seed(0)

# Create a temporary IDX file with valid MNIST format
# Format: magic number (2051), length, num_rows, num_cols, then image data
def create_test_idx_file():
    temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.idx')
    
    magic = 2051  # Magic number for MNIST image files
    length = 2    # Number of images
    num_rows = 4  # Height
    num_cols = 3  # Width
    
    # Write magic number (4 bytes, big-endian)
    temp_file.write(struct.pack('>I', magic))
    # Write length (4 bytes, big-endian)
    temp_file.write(struct.pack('>I', length))
    # Write num_rows (4 bytes, big-endian)
    temp_file.write(struct.pack('>I', num_rows))
    # Write num_cols (4 bytes, big-endian)
    temp_file.write(struct.pack('>I', num_cols))
    
    # Write image data: length * num_rows * num_cols bytes
    image_data = np.random.randint(0, 256, size=(length, num_rows, num_cols), dtype=np.uint8)
    temp_file.write(image_data.tobytes())
    
    temp_file.close()
    return temp_file.name

test_file_path = create_test_idx_file()

ARGS = {
    'path': test_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 3, dtype family int, shape (2, 4, 3) — shape (2, 4, 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
read_label_file Ran
ran, honoured the contract we drafted
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("e983c94b0048922f")
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 Tensor, ndim 1, dtype family int, 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 numpy as np
import torch
import codecs
import tempfile
import os

torch.manual_seed(0)

def get_int(b):
    return int(codecs.encode(b, 'hex'), 16)

# Create a temporary label file with valid MNIST label format
temp_dir = tempfile.mkdtemp()
label_file_path = os.path.join(temp_dir, "labels.bin")

# MNIST label file format:
# - 4 bytes: magic number (2049 in big-endian)
# - 4 bytes: number of labels (big-endian)
# - remaining bytes: label data (uint8)

magic_number = 2049
num_labels = 5
labels_data = np.array([0, 1, 2, 3, 4], dtype=np.uint8)

# Convert to big-endian bytes
magic_bytes = magic_number.to_bytes(4, byteorder='big')
num_labels_bytes = num_labels.to_bytes(4, byteorder='big')
labels_bytes = labels_data.tobytes()

# Write to file
with open(label_file_path, 'wb') as f:
    f.write(magic_bytes)
    f.write(num_labels_bytes)
    f.write(labels_bytes)

ARGS = {
    'path': label_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 1, dtype family int, 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
to_cuda Ran
ran, honoured the contract we drafted
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("00780a5caa71ae85")
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 Tensor, ndim 2, dtype family float, shape (2, 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

torch.manual_seed(0)

# The function takes a single parameter 'x' which should be a torch tensor
# The function checks if CUDA is available and moves it to CUDA if so
# We'll pass a small CPU tensor as input

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
F_MNIST Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("ac3f111fe972ebda")
How it ran

no invocation recorded.

F_MNIST_dataloader Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("9cf1ac4fc94dbc63")
How it ran

no invocation recorded.

build_model Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("5638359173adcc9e")
How it ran

no invocation recorded.

main Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("08246f66c17ce87a")
How it ran

no invocation recorded.

multiclass_noisify Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("5f14559820810bee")
How it ran

no invocation recorded.

noisify Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("ce5a86971e99ddaf")
How it ran

no invocation recorded.

noisify_multiclass_symmetric Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("b6263dc51a463ff5")
How it ran

no invocation recorded.

noisify_pairflip Not yet run
unverified (harvested, no recorded run)
TongtongFANG/DIW/diw.py
code served (permissive licence) · get_code("06e058537f7d4d91")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 10 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
to_cuda
brick of this paper's assembly: helper
3 other papers
1 dated earlier, 2 later
2002.08681 (2020-02)
Unsupervised Multi-Class Domain Adaptation: Theory, Algorithms, and Practice
2206.07551 (2022-06)
Unknown-Aware Domain Adversarial Learning for Open-Set Domain Adaptation
2309.17310 (2023-09)
Leave-one-out Distinguishability in Machine Learning
get_int
brick of this paper's assembly: helper
2 other papers
1 dated earlier, 1 later
1909.03388 (2019-09)
L_DMI: An Information-theoretic Noise-robust Loss Function
2412.06097 (2024-12)
Order Theory in the Context of Machine Learning

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-21.

Repositories linked to this paper

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

Abstract

Under distribution shift (DS) where the training data distribution differs from the test one, a powerful technique is importance weighting (IW) which handles DS in two separate steps: weight estimation (WE) estimates the test-over-training density ratio and weighted classification (WC) trains the classifier from weighted training data. However, IW cannot work well on complex data, since WE is incompatible with deep learning. In this paper, we rethink IW and theoretically show it suffers from a circular dependency: we need not only WE for WC, but also WC for WE where a trained deep classifier is used as the feature extractor (FE). To cut off the dependency, we try to pretrain FE from unweighted training data, which leads to biased FE. To overcome the bias, we propose an end-to-end solution dynamic IW that iterates between WE and WC and combines them in a seamless manner, and hence our WE can also enjoy deep networks and stochastic optimizers indirectly. Experiments with two representative types of DS on three popular datasets show that our dynamic IW compares favorably with state-of-the-art methods.

For agents

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

get_harvested_code_for_paper("2006.04662")
get_code_for_paper("2006.04662")
have("2006.04662")

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

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

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

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

Connect an agent — have() is free.