SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.01233 · 2023

Domain-aware Triplet loss in Domain Generalization

arXiv · PDF · Open in the Atlas

Code that ran

9 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 2 have no contract verdict; 4 failures of our instrument; 3 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/2303.01233.json · badge: /api/ran/2303.01233.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
workerbcd/dct canonical (classifier label)
classifier basis: plan_row
9 ran · 3 no recorded run
FunctionStatusWhere it lives
build_blocks Ran
ran on a synthesized input
workerbcd/dct/domainbed/backbones/new_networks.py
code served (permissive licence) · get_code("83e280af851073dd")
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 2, 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

torch.manual_seed(0)

# Build a simple model with named modules
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Linear(3, 2)
        self.layer3 = nn.Linear(2, 1)
        self.activation = nn.ReLU()
    
    def forward(self, x):
        x = self.layer1(x)
        x = self.activation(x)
        x = self.layer2(x)
        x = self.layer3(x)
        return x

model = SimpleModel()

# Create a block_name_dict that groups module names
block_name_dict = {
    "block_1": ["layer1", "activation"],
    "block_2": ["layer2", "layer3"]
}

ARGS = {
    "model": model,
    "block_name_dict": block_name_dict
}
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 list, ndim 2, 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
get_module Ran
ran; our contract draft was wrong, not the code
workerbcd/dct/domainbed/backbones/new_networks.py
code served (permissive licence) · get_code("c8980fa1301b0ca7")
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 SimpleBlock. 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)

# Build a simple nested module structure
class SimpleBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.block1 = SimpleBlock()
        self.block2 = SimpleBlock()
    
    def forward(self, x):
        x = self.block1(x)
        x = self.block2(x)
        return x

# Create module instance
module = SimpleModel()

# The function iterates through named_modules() and compares names
# We need to provide a valid module and a name that exists in its hierarchy
name = "block1"

ARGS = {
    "module": module,
    "name": name
}
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 SimpleBlock — a SimpleBlock output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleBlock 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
hashable Ran
ran, honoured the contract we drafted
workerbcd/dct/domainbed/lib/query.py
code served (permissive licence) · get_code("71a3a61ceed99bf3")
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 json
import torch

def hashable(obj):
    try:
        hash(obj)
        return obj
    except TypeError:
        return json.dumps({'_': obj}, sort_keys=True)

torch.manual_seed(0)

# Test with a hashable object (int)
hashable_obj = 42

# Test with an unhashable object (list)
unhashable_obj = [1, 2, 3]

ARGS = {
    'obj': hashable_obj
}
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 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
levelize Ran
ran, honoured the contract we drafted
workerbcd/dct/domainbed/lib/logger.py
code served (permissive licence) · get_code("2f597a2077a1c95d")
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 logging

def test_levelize():
    # Test case 1: levelname as string
    levelname_str = "DEBUG"
    
    # Test case 2: levelname as integer
    levelname_int = logging.DEBUG
    
    ARGS = {
        "levelname": levelname_str
    }
    
    return ARGS

ARGS = test_levelize()
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
make_selector_fn Ran
ran; our contract draft was wrong, not the code
workerbcd/dct/domainbed/lib/query.py
code served (permissive licence) · get_code("2f8af5779e1edcb6")
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 types
import torch

torch.manual_seed(0)

# Test case 1: string selector with simple key access
selector_simple_key = "x"

# Test case 2: string selector with nested key access (dot notation)
selector_nested = "x.y"

# Test case 3: string selector with multiple keys (comma notation)
selector_multiple = "x,y"

# Test case 4: function selector
def custom_selector(obj):
    return obj['data']

selector_func = custom_selector

# Create test objects that would work with these selectors
test_obj_simple = {'x': 42}
test_obj_nested = {'x': {'y': 100}}
test_obj_multiple = {'x': 1, 'y': 2}
test_obj_custom = {'data': 'value'}

ARGS = {
    'selector': selector_simple_key
}
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
make_weights_for_balanced_classes Ran
ran on a synthesized input
workerbcd/dct/domainbed/lib/misc.py
code served (permissive licence) · get_code("86798fbb2fc042f5")
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 (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
from collections import Counter

torch.manual_seed(0)

# Construct a simple dataset with dictionaries containing 'y' keys
dataset = [
    {'y': 0, 'x': torch.randn(4)},
    {'y': 0, 'x': torch.randn(4)},
    {'y': 1, 'x': torch.randn(4)},
    {'y': 2, 'x': torch.randn(4)},
]

ARGS = {
    'dataset': dataset
}
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 (4,) — shape (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
random_pairs_of_minibatches Ran
ran; our contract draft was wrong, not the code
workerbcd/dct/domainbed/lib/misc.py
code served (permissive licence) · get_code("4fa2b54178fcc1df")
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. 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)

# Create small minibatches as list of (x, y) tuples
# Each minibatch is ((features_tensor, labels_tensor))
minibatch_1 = (torch.randn(2, 4), torch.randint(0, 2, (2,)))
minibatch_2 = (torch.randn(3, 4), torch.randint(0, 2, (3,)))
minibatch_3 = (torch.randn(2, 4), torch.randint(0, 2, (2,)))

minibatches = [minibatch_1, minibatch_2, minibatch_3]

ARGS = {
    "minibatches": minibatches
}
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 list — a list 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
to_minibatch Ran
ran, honoured the contract we drafted
workerbcd/dct/domainbed/algorithms/algorithms.py
pointer only (licence: MIT); the stored copy get_code serves, from saqibjaved1/QT-DoG, is pointer only (licence: NONE) · get_code("12c23ce22097acd0")
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 saqibjaved1/QT-DoG, 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.

to_row Ran
ran; our contract draft was wrong, not the code
workerbcd/dct/domainbed/lib/misc.py
code served (permissive licence) · get_code("5dd6a674fbe45a89")
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 numpy as np

# Construct a simple row of mixed values
row = [1.234567, 2.5, "text", 42, 3.14159265]

# Test with default parameters
ARGS = {
    "row": row,
    "colwidth": 10,
    "latex": False
}
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 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
accuracy_from_loader Not yet run
unverified (harvested, no recorded run)
workerbcd/dct/domainbed/evaluator.py
code served (permissive licence) · get_code("0ca4d46da891e3df")
How it ran

no invocation recorded.

default_hparams Not yet run
unverified (harvested, no recorded run)
workerbcd/dct/domainbed/hparams_registry.py
code served (permissive licence) · get_code("480b953f8f91b3b1")
How it ran

no invocation recorded.

random_hparams Not yet run
unverified (harvested, no recorded run)
workerbcd/dct/domainbed/hparams_registry.py
code served (permissive licence) · get_code("dbeb3657dc35373d")
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, 9 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 0 the same month, 9 later) and 3 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
hashable 20 other papers
9 dated earlier, 11 later
2106.02266 (2021-06)
SAND-mask: An Enhanced Gradient Masking Strategy for the Discovery of Invariances in Domain Generalization
2111.12853 (2021-11)
Domain Prompt Learning for Efficiently Adapting CLIP to Unseen Domains
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
and 17 more not named here
make_selector_fn 20 other papers
9 dated earlier, 11 later
2106.02266 (2021-06)
SAND-mask: An Enhanced Gradient Masking Strategy for the Discovery of Invariances in Domain Generalization
2111.12853 (2021-11)
Domain Prompt Learning for Efficiently Adapting CLIP to Unseen Domains
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
and 17 more not named here
random_pairs_of_minibatches 7 other papers
3 dated earlier, 4 later
2110.09410 (2021-10)
Exploiting Domain-Specific Features to Enhance Domain Generalization
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
and 4 more not named here
to_minibatch 7 other papers
2 dated earlier, 5 later
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
2305.13046 (2023-05)
POEM: Polarization of Embeddings for Domain-Invariant Representations
and 4 more not named here
levelize 6 other papers
3 dated earlier, 3 later
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2206.04046 (2022-06)
Sparse Mixture-of-Experts are Domain Generalizable Learners
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
and 3 more not named here
default_hparams 5 other papers
2 dated earlier, 3 later
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
2305.13046 (2023-05)
POEM: Polarization of Embeddings for Domain-Invariant Representations
and 2 more not named here
random_hparams 5 other papers
2 dated earlier, 3 later
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
2305.13046 (2023-05)
POEM: Polarization of Embeddings for Domain-Invariant Representations
and 2 more not named here
to_row 5 other papers
2 dated earlier, 3 later
2203.10789 (2022-03)
Domain Generalization by Mutual-Information Regularization with Pre-trained Models
2302.14685 (2023-02)
DART: Diversify-Aggregate-Repeat Training Improves Generalization of Neural Networks
2305.13046 (2023-05)
POEM: Polarization of Embeddings for Domain-Invariant Representations
and 2 more not named here
get_module 1 other paper
1 later
2310.19224 (2023-10)
CHAMMI: A benchmark for channel-adaptive models in microscopy imaging

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

Despite much progress being made in the field of object recognition with the advances of deep learning, there are still several factors negatively affecting the performance of deep learning models. Domain shift is one of these factors and is caused by discrepancies in the distributions of the testing and training data. In this paper, we focus on the problem of compact feature clustering in domain generalization to help optimize the embedding space from multi-domain data. We design a domainaware triplet loss for domain generalization to help the model to not only cluster similar semantic features, but also to disperse features arising from the domain. Unlike previous methods focusing on distribution alignment, our algorithm is designed to disperse domain information in the embedding space. The basic idea is motivated based on the assumption that embedding features can be clustered based on domain information, which is mathematically and empirically supported in this paper. In addition, during our exploration of feature clustering in domain generalization, we note that factors affecting the convergence of metric learning loss in domain generalization are more important than the pre-defined domains. To solve this issue, we utilize two methods to normalize the embedding space, reducing the internal covariate shift of the embedding features. The ablation study demonstrates the effectiveness of our algorithm. Moreover, the experiments on the benchmark datasets, including PACS, VLCS and Office-Home, show that our method outperforms related methods focusing on domain discrepancy. In particular, our results on RegnetY-16 are significantly better than state-of-the-art methods on the benchmark datasets. Our code will be released at https://github.com/workerbcd/DCT

For agents

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

get_harvested_code_for_paper("2303.01233")
get_code_for_paper("2303.01233")
have("2303.01233")

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

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

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

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

Connect an agent — have() is free.