SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.09645 · ICML · 2022

Improving Mini-batch Optimal Transport via Partial Transportation

Nhat Ho, Dang Nguyen, Khai Nguyen, Tung Pham, Anh Vu-Le

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 4 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/2108.09645.json · badge: /api/ran/2108.09645.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
khainb/BoMb-OT marked official in Papers with Code
Papers with Code archive
6 ran · 3 no recorded run
ut-austin-data-science-group/mini-batch-ot reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
0 ran · 1 no recorded run
FunctionStatusWhere it lives
BalancedBatchSampler Ran
ran on a synthesized input · constructed an object; no result was computed
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("a2d1ed9ac5b514b0")
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 an instance of its own class, BalancedBatchSampler: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)
np.random.seed(0)

# Create a simple label tensor with multiple classes
# We need enough samples per class and enough total samples
# Let's create 20 samples across 4 classes (5 samples per class)
labels = torch.tensor([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3])

# batch_size must be >= n_classes and divisible considerations
# With 4 classes, batch_size = 8 gives us 2 samples per class
batch_size = 8

ARGS = {
    "labels": labels,
    "batch_size": batch_size,
}
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 BalancedBatchSampler — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BalancedBatchSampler 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
BoMbOT Ran
ran; our contract draft was wrong, not the code
ut-austin-data-science-group/mini-batch-ot/ABC/utils.py
code served (permissive licence) · get_code("4e7fbdb2bc8ec056")
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 float64, ndim 0, 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
import ot

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

# Create small sample data
# x and y should be 2D arrays where rows are samples and columns are features
x = np.random.randn(8, 4)  # 8 samples, 4 features
y = np.random.randn(8, 4)  # 8 samples, 4 features

# Parameters
k = 2  # number of blocks to sample
m = 2  # divisor for determining block size (n/m blocks of size m)

ARGS = {
    "x": x,
    "y": y,
    "k": k,
    "m": m
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, ot — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
ImageList Ran
ran on a synthesized input · constructed an object; no result was computed
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("76825d32647cb3ce")
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 an instance of its own class, ImageList: the run constructed the object and did not call it, so no result was computed. 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
from torchvision import transforms
import tempfile
import os
from PIL import Image

# Create temporary test images
temp_dir = tempfile.mkdtemp()

# Create a simple RGB image
rgb_img = Image.new('RGB', (32, 32), color=(73, 109, 137))
rgb_path = os.path.join(temp_dir, 'test_rgb.png')
rgb_img.save(rgb_path)

# Create a simple L (grayscale) image
l_img = Image.new('L', (32, 32), color=128)
l_path = os.path.join(temp_dir, 'test_l.png')
l_img.save(l_path)

# Prepare image_list - list of strings with path and label
image_list = [
    f'{rgb_path} 0',
    f'{l_path} 1'
]

# Prepare labels as numpy array (optional parameter)
labels = np.array([[0], [1]], dtype=np.float32)

# Create simple transforms
transform = transforms.Compose([
    transforms.ToTensor(),
])

target_transform = transforms.Compose([
    transforms.Lambda(lambda x: torch.tensor(x, dtype=torch.long))
])

ARGS = {
    'image_list': image_list,
    'labels': None,  # Can be None or labels array
    'transform': transform,
    'target_transform': target_transform,
    'mode': 'RGB'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ImageList — the run constructed an instance of its own class and did not call it; no shape 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
InfiniteSliceIterator Ran
ran on a synthesized input · constructed an object; no result was computed
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("978e1da65a934d3a")
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 an instance of its own class, InfiniteSliceIterator: the run constructed the object and did not call it, so no result was computed. 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 numpy as np

# Construct a small numpy array for testing
array = np.array([1, 2, 3, 4, 5], dtype=np.int32)

# Define the class label/identifier
class_label = "class_0"

# Create the ARGS dictionary
ARGS = {
    "array": array,
    "class_": class_label,
}
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 InfiniteSliceIterator — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a InfiniteSliceIterator 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
image_test Ran
ran; our contract draft was wrong, not the code
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("60166088c825b407")
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 Compose. 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
from torchvision import transforms

torch.manual_seed(0)

ARGS = {
    "resize_size": 256,
    "crop_size": 224,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
image_train Ran
ran; our contract draft was wrong, not the code
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("6d14e3fcb8d93fa1")
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 Compose. 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
from torchvision import transforms

torch.manual_seed(0)

ARGS = {
    "resize_size": 256,
    "crop_size": 224,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
inv_lr_scheduler Ran
ran; our contract draft was wrong, not the code
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("693fef7015113684")
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 SGD. 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
import torch.optim as optim

torch.manual_seed(0)

# Create a small model
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.fc(x)

model = SimpleModel()

# Create optimizer with param_groups that have lr_mult and decay_mult
optimizer = optim.SGD([
    {'params': model.fc.weight, 'lr_mult': 1.0, 'decay_mult': 1.0},
    {'params': model.fc.bias, 'lr_mult': 2.0, 'decay_mult': 0.5}
], lr=0.001, weight_decay=0.0005)

ARGS = {
    'optimizer': optimizer,
    'iter_num': 100,
    'gamma': 0.0001,
    'power': 0.75,
    'lr': 0.001,
    'weight_decay': 0.0005
}
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 SGD — a SGD output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SGD 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
ResNetFc Not yet run
unverified (harvested, no recorded run)
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("4fde4b15ac469854")
How it ran

no invocation recorded.

VGGFc Not yet run
unverified (harvested, no recorded run)
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("0fa0506a51ba91fa")
How it ran

no invocation recorded.

image_classification Not yet run
unverified (harvested, no recorded run)
this paper's copy was not recorded; identical code first harvested from kilianFatras/JUMBOT
pointer only · get_code("b42e76c69ec6ec9c")
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. No invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
khainb/BoMb-OT/PartialDA/run_mOT.py
code served (permissive licence) · get_code("4ecaced2e83b4ff1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 1 later) and 7 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
inv_lr_scheduler
brick of this paper's assembly: helper
4 other papers
2 dated earlier, 2 later · 1 only as an assembly brick
2003.02541 (2020-03)
A Balanced and Uncertainty-aware Approach for Partial Domain Adaptation
2104.00808 (2021-04)
Curriculum Graph Co-Teaching for Multi-Target Domain Adaptation
2402.01887 (2024-02)
On f -Divergence Principled Domain Adaptation: An Improved Framework
and 1 more not named here
image_classification
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2103.03606 (2021-03)
Unbalanced minibatch Optimal Transport; applications to Domain Adaptation
image_test
brick of this paper's assembly: data_transform
1 other paper
1 dated earlier
2003.02541 (2020-03)
A Balanced and Uncertainty-aware Approach for Partial Domain Adaptation
image_train
brick of this paper's assembly: data_transform
1 other paper
1 dated earlier
2003.02541 (2020-03)
A Balanced and Uncertainty-aware Approach for Partial Domain Adaptation

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

Mini-batch optimal transport (m-OT) has been widely used recently to deal with the memory issue of OT in large-scale applications. Despite their practicality, m-OT suffers from misspecified mappings, namely, mappings that are optimal on the mini-batch level but are partially wrong in the comparison with the optimal transportation plan between the original measures. Motivated by the misspecified mappings issue, we propose a novel mini-batch method by using partial optimal transport (POT) between mini-batch empirical measures, which we refer to as mini-batch partial optimal transport (m-POT). Leveraging the insight from the partial transportation, we explain the source of misspecified mappings from the m-OT and motivate why limiting the amount of transported masses among mini-batches via POT can alleviate the incorrect mappings. Finally, we carry out extensive experiments on various applications such as deep domain adaptation, partial domain adaptation, deep generative model, color transfer, and gradient flow to demonstrate the favorable performance of m-POT compared to current mini-batch methods.

For agents

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

get_harvested_code_for_paper("2108.09645")
get_code_for_paper("2108.09645")
have("2108.09645")

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

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

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

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

Connect an agent — have() is free.