SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.04003 · 2021

Improving Deep Metric Learning by Divide and Conquer

arXiv · PDF · Open in the Atlas

Code that ran

12 of 16 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 10 have no contract verdict; 2 failures of our instrument; 4 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/2109.04003.json · badge: /api/ran/2109.04003.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
compvis/metric-learning-divide-and-conquer-improved canonical (classifier label)
classifier basis: census
12 ran · 4 no recorded run
FunctionStatusWhere it lives
empty_if_default Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/experiment/margin_loss_resnet50.py
code served (permissive licence) · get_code("f35dabf7a95feead")
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 str. 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

def empty_if_default(value, default_value):
    if value != default_value:
        return '-' + str(value)
    else:
        return ''

ARGS = {
    'value': 42,
    'default_value': 100
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
fetch_recall Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/eval_model.py
code served (permissive licence) · get_code("7e2ff61e53717e1a")
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 list, 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 torch
import numpy as np

# Analyze the function:
# - fetch_recall(metrics, max_e=400)
# - Iterates over metrics dict keys (m)
# - Checks if m < max_e and m >= 0
# - Accesses metrics[m]['score']['eval']['final'][1][0]
# - Returns a list of those values

# metrics must be a dict with integer keys
# Each value must have nested structure: ['score']['eval']['final'][1][0]
# The innermost access [1][0] suggests a 2D array/list

torch.manual_seed(0)

# Construct a metrics dict with proper nested structure
metrics = {
    0: {
        'score': {
            'eval': {
                'final': [
                    [1.1, 2.2],  # [0]
                    [3.3, 4.4]   # [1]
                ]
            }
        }
    },
    10: {
        'score': {
            'eval': {
                'final': [
                    [5.5, 6.6],
                    [7.7, 8.8]
                ]
            }
        }
    },
    100: {
        'score': {
            'eval': {
                'final': [
                    [9.9, 10.1],
                    [11.11, 12.12]
                ]
            }
        }
    },
    500: {
        'score': {
            'eval': {
                'final': [
                    [13.13, 14.14],
                    [15.15, 16.16]
                ]
            }
        }
    },
    -5: {
        'score': {
            'eval': {
                'final': [
                    [17.17, 18.18],
                    [19.19, 20.20]
                ]
            }
        }
    }
}

ARGS = {
    'metrics': metrics,
    'max_e': 400
}
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 list, ndim 1, dtype family float — a list 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
index_dataset Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/dataset/npairs.py
code served (permissive licence) · get_code("b38d84edfb1e99ae")
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 dict. 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 numpy as np

class MockDataset:
    def __init__(self, im_paths, ys):
        self.im_paths = im_paths
        self.ys = ys

# Create a small mock dataset
im_paths = ['image_0.jpg', 'image_1.jpg', 'image_2.jpg', 'image_3.jpg']
ys = [0, 1, 0, 2]

dataset = MockDataset(im_paths, ys)

ARGS = {
    'dataset': dataset
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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_args Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/experiment/base.py
code served (permissive licence) · get_code("cfde26759e9d9c42")
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 dict. 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

torch.manual_seed(0)

# Create minimal dataset_roots dictionary
dataset_roots = {
    'vid': '/tmp/vid',
    'inshop': '/tmp/inshop',
    'cub': '/tmp/cub',
    'cars': '/tmp/cars',
    'sop': '/tmp/sop'
}

ARGS = {
    'dataset_roots': dataset_roots
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
merge_clusters Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/utils.py
code served (permissive licence) · get_code("12d14d2613022a8b")
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 int, shape (8,) 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

# Create a simple cluster assignment array
# C should be a 1D or 2D numpy array with integer cluster IDs
C = np.array([0, 1, 2, 3, 4, 5, 6, 7], dtype=np.int32)

# gpu_ids is optional and not used in the function body
gpu_ids = None

ARGS = {
    "C": C,
    "gpu_ids": gpu_ids
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 1, dtype family int, shape (8,) — shape (8,) 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
parse_bool Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/experiment/margin_loss_resnet50.py
code served (permissive licence) · get_code("88137d9a7fe8cbfe")
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 bool, 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

ARGS = {
    'val': '1'
}
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 bool, 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
parse_clustering_method Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/experiment/margin_loss_resnet50.py
code served (permissive licence) · get_code("aa9272a8a0d334bf")
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 dict. 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

torch.manual_seed(0)

ARGS = {
    'val': 'kmeans'
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
run Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/collect_env_info.py
code served (permissive licence) · get_code("6f559a6380486ff9")
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, 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 locale
import subprocess
import sys

PY3 = sys.version_info >= (3, 0)

def run(command):
    """Returns (return-code, stdout, stderr)"""
    p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    output, err = p.communicate()
    rc = p.returncode
    if PY3:
        enc = locale.getpreferredencoding()
        output = output.decode(enc)
        err = err.decode(enc)
    return (rc, output.strip(), err.strip())

ARGS = {
    "command": "echo 'Hello World'"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
run_and_parse_first_match Ran
ran; our contract draft was wrong, not the code
compvis/metric-learning-divide-and-conquer-improved/collect_env_info.py
pointer only (licence: MIT); the stored copy get_code serves, from NolanKoblischke/SpectraFM_NeurIPS_FM4Science, is pointer only (licence: NONE) · get_code("ab7aeddfa9e9fb2e")
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 NolanKoblischke/SpectraFM_NeurIPS_FM4Science, 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.

run_and_read_all Ran
ran; our contract draft was wrong, not the code
compvis/metric-learning-divide-and-conquer-improved/collect_env_info.py
pointer only (licence: MIT); the stored copy get_code serves, from NolanKoblischke/SpectraFM_NeurIPS_FM4Science, is pointer only (licence: NONE) · get_code("84905132fbc263e3")
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 NolanKoblischke/SpectraFM_NeurIPS_FM4Science, 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.

sample_from_class Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/dataset/npairs.py
code served (permissive licence) · get_code("8b0a5832a7d73092")
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
import random

torch.manual_seed(0)

# Construct images_by_class: a dict where keys are class indices
# and values are lists of images (we'll use small tensors as stand-ins)
images_by_class = {
    0: [torch.randn(2, 4), torch.randn(2, 4), torch.randn(2, 4)],
    1: [torch.randn(2, 4), torch.randn(2, 4)],
    2: [torch.randn(2, 4)],
}

# class_label_ind is an integer index into the images_by_class dict
class_label_ind = 0

ARGS = {
    "images_by_class": images_by_class,
    "class_label_ind": class_label_ind,
}
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
train_kmeans Ran
ran on a synthesized input
compvis/metric-learning-divide-and-conquer-improved/metriclearning/faissext.py
code served (permissive licence) · get_code("f9c73077030737d4")
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 (5, 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 numpy as np
import faiss
import logging

# Set up logging to suppress debug messages during test
logging.basicConfig(level=logging.WARNING)

# Create a small random dataset for k-means clustering
# Shape: (num_samples, feature_dim)
# Using small sizes: 20 samples, 4 features
np.random.seed(1234)
x = np.random.randn(20, 4).astype(np.float32)

# Ensure no NaN or Inf values
assert np.all(~np.isnan(x))
assert np.all(np.isfinite(x))

ARGS = {
    'x': x,
    'num_clusters': 5,
    'gpu_ids': None,  # CPU only
    'niter': 10,
    'nredo': 1,
    'verbose': 0,
    'seed': 1234
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
faiss, 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, 4) — shape (5, 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
is_match Not yet run
unverified (harvested, no recorded run)
compvis/metric-learning-divide-and-conquer-improved/browse_results.py
code served (permissive licence) · get_code("d9a66474dd07a91d")
How it ran

no invocation recorded.

preprocess_features Not yet run
unverified (harvested, no recorded run)
compvis/metric-learning-divide-and-conquer-improved/metriclearning/faissext.py
code served (permissive licence) · get_code("38ac9dc17918d04e")
How it ran

no invocation recorded.

reassign_clusters Not yet run
unverified (harvested, no recorded run)
compvis/metric-learning-divide-and-conquer-improved/dataset/loader.py
code served (permissive licence) · get_code("93db13d8a6478b7c")
How it ran

no invocation recorded.

reserve_faiss_gpu_memory Not yet run
unverified (harvested, no recorded run)
compvis/metric-learning-divide-and-conquer-improved/metriclearning/faissext.py
code served (permissive licence) · get_code("094e0f4940c1d413")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 2 the same month, 2 later) and 14 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
run_and_parse_first_match 14 other papers
1 the same month, 13 later
2109.08267 (2021-09)
CompilerGym: Robust, Performant Compiler Optimization Environments for AI Research
2202.04053 (2022-02)
DALL-Eval: Probing the Reasoning Skills and Social Biases of Text-to-Image Generation Models
2309.06180 (2023-09)
Efficient Memory Management for Large Language Model Serving with PagedAttention
and 11 more not named here
run_and_read_all 14 other papers
1 the same month, 13 later
2109.08267 (2021-09)
CompilerGym: Robust, Performant Compiler Optimization Environments for AI Research
2202.04053 (2022-02)
DALL-Eval: Probing the Reasoning Skills and Social Biases of Text-to-Image Generation Models
2309.06180 (2023-09)
Efficient Memory Management for Large Language Model Serving with PagedAttention
and 11 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

Deep metric learning (DML) is a cornerstone of many computer vision applications. It aims at learning a mapping from the input domain to an embedding space, where semantically similar objects are located nearby and dissimilar objects far from another. The target similarity on the training data is defined by user in form of ground-truth class labels. However, while the embedding space learns to mimic the user-provided similarity on the training data, it should also generalize to novel categories not seen during training. Besides user-provided groundtruth training labels, a lot of additional visual factors (such as viewpoint changes or shape peculiarities) exist and imply different notions of similarity between objects, affecting the generalization on the images unseen during training. However, existing approaches usually directly learn a single embedding space on all available training data, struggling to encode all different types of relationships, and do not generalize well. We propose to build a more expressive representation by jointly splitting the embedding space and the data hierarchically into smaller sub-parts. We successively focus on smaller subsets of the training data, reducing its variance and learning a different embedding subspace for each data subset. Moreover, the subspaces are learned jointly to cover not only the intricacies, but the breadth of the data as well. Only after that, we build the final embedding from the subspaces in the conquering stage. The proposed algorithm acts as a transparent wrapper that can be placed around arbitrary existing DML methods. Our approach significantly improves upon the state-of-the-art on image retrieval, clustering, and re-identification tasks evaluated using CUB200-2011, CARS196, Stanford Online Products, In-shop Clothes, and PKU VehicleID datasets.

For agents

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

get_harvested_code_for_paper("2109.04003")
get_code_for_paper("2109.04003")
have("2109.04003")

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

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

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

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

Connect an agent — have() is free.