SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.13575 · CVPR · 2021

MetaAlign: Coordinating Domain Alignment and Classification for Unsupervised Domain Adaptation

Wenjun Zeng, Cuiling Lan, Zhibo Chen, Guoqiang Wei

arXiv · PDF · Open in the Atlas

Code that ran

5 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; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 7 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/2103.13575.json · badge: /api/ran/2103.13575.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
microsoft/UDA community
Papers with Code archive
5 ran · 7 no recorded run
FunctionStatusWhere it lives
WeightBCE Ran
ran on a synthesized input
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("1abfdd785dd465dc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, 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 torch
import torch.nn as nn
from torch import Tensor

class WeightBCE(nn.Module):

    def __init__(self, epsilon: float=1e-08) -> None:
        super(WeightBCE, self).__init__()
        self.epsilon = epsilon

    def forward(self, x: Tensor, label: Tensor, weight: Tensor) -> Tensor:
        """
        :param x: [N, 1]
        :param label: [N, 1]
        :param weight: [N, 1]
        """
        label = label.float()
        cross_entropy = -label * torch.log(x + self.epsilon) - (1 - label) * torch.log(1 - x + self.epsilon)
        return torch.sum(cross_entropy * weight.float()) / 2.0


INIT_ARGS = {
    'epsilon': 1e-08
}

ARGS = {
    'x': torch.tensor([[0.7], [0.3], [0.9], [0.1]], dtype=torch.float32),
    'label': torch.tensor([[1.0], [0.0], [1.0], [0.0]], dtype=torch.float32),
    'weight': torch.tensor([[1.0], [2.0], [0.5], [1.5]], dtype=torch.float32)
}

if __name__ == '__main__':
    model = WeightBCE(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 0, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
d_align_uda Ran
ran; our contract draft was wrong, not the code
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("0684cec8a1bb4ee7")
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 0, dtype family float; no output shape is stated. 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 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 torch.nn as nn
from torch import Tensor

torch.manual_seed(0)

class SimpleDiscriminator(nn.Module):
    def __init__(self):
        super(SimpleDiscriminator, self).__init__()
        self.fc = nn.Linear(10, 1)
    
    def forward(self, x: Tensor, coeff: float = None) -> Tensor:
        return self.fc(x)

batch_size = 2
num_classes = 3
feature_dim = 10

softmax_output = torch.rand(batch_size * 2, num_classes)
softmax_output = softmax_output / softmax_output.sum(dim=1, keepdim=True)

features = torch.randn(batch_size * 2, feature_dim)

d_net = SimpleDiscriminator()

coeff = 0.5

ARGS = {
    "softmax_output": softmax_output,
    "features": features,
    "d_net": d_net,
    "coeff": coeff,
    "ent": False,
}
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 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
entropy_func Ran
ran; our contract draft was wrong, not the code
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("8b9cea73effc2f3f")
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 (2,) 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
from torch import Tensor

torch.manual_seed(0)

# Create a valid probability distribution tensor
# Shape: [N=2, C=4] representing probability distributions
# Values should be in [0, 1] range and sum to 1 along dim 1
x = torch.tensor([
    [0.1, 0.2, 0.3, 0.4],
    [0.25, 0.25, 0.25, 0.25]
], dtype=torch.float32)

ARGS = {
    "x": x
}
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 (2,) — shape (2,) 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
grl_hook Ran
ran; our contract draft was wrong, not the code
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("1374e0a62b470535")
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 function. 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

torch.manual_seed(0)

# The function grl_hook takes a coefficient and returns a gradient reversal hook function
# The hook function multiplies gradients by -coeff
# We need to provide a valid coefficient value

ARGS = {
    "coeff": 0.5
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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, honoured the contract we drafted
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("0a5764019d61e108")
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 float, 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
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0)

# Create a simple model
model = nn.Linear(4, 3)

# Create an optimizer with param_groups that have 'lr_mult' attribute
optimizer = optim.SGD(model.parameters(), lr=0.001)

# Add 'lr_mult' to each param_group (this is what the function uses)
for param_group in optimizer.param_groups:
    param_group['lr_mult'] = 1.0

# Define arguments for inv_lr_scheduler
ARGS = {
    'optimizer': optimizer,
    'ite_rate': 0.5,
    'gamma': 10.0,
    'power': 0.75,
    'lr': 0.001
}
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 float, 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
BaseTrainer Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("e4d8b30d56dbb7f3")
How it ran

no invocation recorded.

DANN Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("41a98ec5329fd73f")
How it ran

no invocation recorded.

ToAlign Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("749e206ff3a3ceb8")
How it ran

no invocation recorded.

d_align_msda Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("4233973b97f8665f")
How it ran

no invocation recorded.

get_coeff Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("d56aff948c2f12a0")
How it ran

no invocation recorded.

save_model Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("e320fa657d11368b")
How it ran

no invocation recorded.

write_log Not yet run
unverified (harvested, no recorded run)
microsoft/UDA/trainer/da/toalign.py
code served (permissive licence) · get_code("e04cd9b9c5fb70e0")
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, 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 12 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

For unsupervised domain adaptation (UDA), to alleviate the effect of domain shift, many approaches align the source and target domains in the feature space by adversarial learning or by explicitly aligning their statistics. However, the optimization objective of such domain alignment is generally not coordinated with that of the object classification task itself such that their descent directions for optimization may be inconsistent. This will reduce the effectiveness of domain alignment in improving the performance of UDA. In this paper, we aim to study and alleviate the optimization inconsistency problem between the domain alignment and classification tasks. We address this by proposing an effective meta-optimization based strategy dubbed MetaAlign, where we treat the domain alignment objective and the classification objective as the meta-train and meta-test tasks in a meta-learning scheme. MetaAlign encourages both tasks to be optimized in a coordinated way, which maximizes the inner product of the gradients of the two tasks during training. Experimental results demonstrate the effectiveness of our proposed method on top of various alignment-based baseline approaches, for tasks of object classification and object detection. MetaAlign helps achieve the state-of-the-art performance.

For agents

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

get_harvested_code_for_paper("2103.13575")
get_code_for_paper("2103.13575")
have("2103.13575")

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

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

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

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

Connect an agent — have() is free.