SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2003.06777 · 2020

DeepEMD: Differentiable Earth Mover's Distance for Few-Shot Learning

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 2 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/2003.06777.json · badge: /api/ran/2003.06777.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
icoz69/DeepEMD community (classifier label)
classifier basis not recorded on the link
5 ran · 2 no recorded run
FunctionStatusWhere it lives
compute_confidence_interval Ran
ran, honoured the contract we drafted
icoz69/DeepEMD/Models/utils.py
code served (permissive licence) · get_code("81ea193467a90dc6")
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 numpy as np

# The function takes a single parameter 'data' which should be an array-like
# of numerical values (mean accuracy or mAP across sampled episodes).
# The function computes mean, std, and sqrt operations on it.

# Create sample data: an array of mean accuracies across multiple episodes
data = np.array([0.85, 0.87, 0.84, 0.88, 0.86, 0.89, 0.83, 0.87])

ARGS = {
    "data": data
}
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 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
conv3x3 Ran
ran; our contract draft was wrong, not the code
icoz69/DeepEMD/Models/models/resnet.py
pointer only (licence: MIT); the stored copy get_code serves, from lixiaotong97/DSU, is pointer only (licence: NONE) · get_code("fac5364e2f53c6db")
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 lixiaotong97/DSU, 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.

emd_inference_opencv Ran
ran on a synthesized input
icoz69/DeepEMD/Models/models/emd_utils.py
code served (permissive licence) · get_code("829d4aa345489492")
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.functional as F
import numpy as np

torch.manual_seed(0)

# Create small tensors for the function
# cost_matrix should be a 2D tensor (comparing two sets of points)
cost_matrix = torch.randn(3, 4)

# weight1 and weight2 should be 1D tensors that represent weights/masses
# They need to have the same length as the dimensions they correspond to in cost_matrix
weight1 = torch.randn(3)
weight2 = torch.randn(4)

ARGS = {
    "cost_matrix": cost_matrix,
    "weight1": weight1,
    "weight2": weight2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy, 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
emd_inference_opencv_test Ran
ran on a synthesized input
icoz69/DeepEMD/Models/models/emd_utils.py
code served (permissive licence) · get_code("4d2e05bc40a813cc")
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. 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.functional as F

torch.manual_seed(0)

# distance_matrix: shape (batch_size, n, m) where n and m are point set sizes
# weight1: shape (batch_size, n) - weights for first point set
# weight2: shape (batch_size, m) - weights for second point set

batch_size = 2
n_points_1 = 3
n_points_2 = 4

# Create cost/distance matrices for each sample in batch
distance_matrix = torch.randn(batch_size, n_points_1, n_points_2, dtype=torch.float32)

# Create weight tensors with positive values
weight1 = torch.rand(batch_size, n_points_1, dtype=torch.float32) + 0.1
weight2 = torch.rand(batch_size, n_points_2, dtype=torch.float32) + 0.1

ARGS = {
    "distance_matrix": distance_matrix,
    "weight1": weight1,
    "weight2": weight2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, 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
set_gpu Ran
ran, honoured the contract we drafted
icoz69/DeepEMD/Models/utils.py
code served (permissive licence) · get_code("8327880f0b76f9db")
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 os

class Args:
    def __init__(self, gpu):
        self.gpu = gpu

ARGS = {
    'args': Args(gpu='0,1')
}
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 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
count_acc Not yet run
unverified (harvested, no recorded run)
icoz69/DeepEMD/Models/utils.py
code served (permissive licence) · get_code("684d8ecbca8220ab")
How it ran

no invocation recorded.

set_up_datasets Not yet run
unverified (harvested, no recorded run)
icoz69/DeepEMD/Models/dataloader/data_utils.py
code served (permissive licence) · get_code("3a753faa7bc9cb2b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 6 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 6 later) and 1 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
conv3x3 686 other papers
197 dated earlier, 17 the same month, 471 later, 1 same year, order not determinable · 31 only as an assembly brick
1406.2661 (2014-06)
Generative Adversarial Networks
1409.0575 (2014-09)
ImageNet Large Scale Visual Recognition Challenge
1412.6572 (2014-12)
Explaining and Harnessing Adversarial Examples
and 683 more not named here
count_acc 4 other papers
1 dated earlier, 3 later
1906.02944 (2019-06)
Learning Adaptive Classifiers Synthesis for Generalized Few-Shot Learning
2104.03047 (2021-04)
Few-Shot Incremental Learning with Continually Evolved Classifiers
2210.04524 (2022-10)
Margin-Based Few-Shot Class-Incremental Learning with Class-Level Overfitting Mitigation
and 1 more not named here
set_gpu 4 other papers
4 later
2104.03047 (2021-04)
Few-Shot Incremental Learning with Continually Evolved Classifiers
2210.04524 (2022-10)
Margin-Based Few-Shot Class-Incremental Learning with Class-Level Overfitting Mitigation
2404.02117 (2024-04)
Pre-trained Vision and Language Transformers Are Few-Shot Incremental Learners
and 1 more not named here
compute_confidence_interval 3 other papers
3 later
2109.02221 (2021-09)
Nearest Neighbour Few-Shot Learning for Cross-lingual Classification
2110.02210 (2021-10)
Mix3D: Out-of-Context Data Augmentation for 3D Scenes
2211.15059 (2022-11)
Learning Dense Object Descriptors from Multiple Views for Low-shot Category Generalization
emd_inference_opencv 1 other paper
1 later
2303.15111 (2023-03)
Learning Attention as Disentangler for Compositional Zero-shot Learning
emd_inference_opencv_test 1 other paper
1 later
2303.15111 (2023-03)
Learning Attention as Disentangler for Compositional Zero-shot 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

In this work, we develop methods for few-shot image classification from a new perspective of optimal matching between image regions. We employ the Earth Mover's Distance (EMD) as a metric to compute a structural distance between dense image representations to determine image relevance. The EMD generates the optimal matching flows between structural elements that have the minimum matching cost, which is used to calculate the image distance for classification. To generate the important weights of elements in the EMD formulation, we design a cross-reference mechanism, which can effectively alleviate the adverse impact caused by the cluttered background and large intra-class appearance variations. To implement k-shot classification, we propose to learn a structured fully connected layer that can directly classify dense image representations with the EMD. Based on the implicit function theorem, the EMD can be inserted as a layer into the network for end-to-end training. Our extensive experiments validate the effectiveness of our algorithm which outperforms state-of-the-art methods by a significant margin on five widely used few-shot classification benchmarks, namely, miniImageNet, tieredImageNet, Fewshot-CIFAR100 (FC100), Caltech-UCSD Birds-200-2011 (CUB), and CIFAR-FewShot (CIFAR-FS). We also demonstrate the effectiveness of our method on the image retrieval task in our experiments.

For agents

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

get_harvested_code_for_paper("2003.06777")
get_code_for_paper("2003.06777")
have("2003.06777")

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

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

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

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

Connect an agent — have() is free.