SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2007.11498 · NeurIPS · 2020

CrossTransformers: spatially-aware few-shot transfer

Andrew Zisserman, Carl Doersch, Ankush Gupta

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 1 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/2007.11498.json · badge: /api/ran/2007.11498.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
skrish13/CrossTransformers-PyTorch reimplementation (classifier label)
classifier basis: classifier_2025
2 ran · 1 no recorded run
vinuni-vishc/Few-Shot-Cosine-Transformer community
Papers with Code archive
2 ran · 0 no recorded run
lucidrains/cross-transformers-pytorch community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
CTX Ran
ran on a synthesized input · constructed an object; no result was computed
vinuni-vishc/Few-Shot-Cosine-Transformer/methods/CTX.py
pointer only (licence: NOASSERTION) · get_code("b853d61344e2e673")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, vinuni-vishc/Few-Shot-Cosine-Transformer (NOASSERTION). 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.

CrossTransformer Ran
ran on a synthesized input
lucidrains/cross-transformers-pytorch/cross_transformers_pytorch/cross_transformers_pytorch.py
code served (permissive licence) · get_code("fbc03a7cd28cb716")
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 2, dtype family float, shape (2, 3) 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 nn
import torch.nn.functional as F
from einops import rearrange

class DummyModel(nn.Module):
    """Stand-in model that processes images and returns feature maps"""
    def __init__(self, in_channels=3, out_channels=512):
        super().__init__()
        self.conv = nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1)
    
    def forward(self, x):
        return self.conv(x)

from torch import nn, einsum
from einops import rearrange

class CrossTransformer(nn.Module):

    def __init__(self, dim=512, dim_key=128, dim_value=128):
        super().__init__()
        self.scale = dim_key ** (-0.5)
        self.to_qk = nn.Conv2d(dim, dim_key, 1, bias=False)
        self.to_v = nn.Conv2d(dim, dim_value, 1, bias=False)

    def forward(self, model, img_query, img_supports):
        """
        dimensions names:
        
        b - batch
        k - num classes
        n - num images in a support class
        c - channels
        h, i - height
        w, j - width
        """
        b, k, *_ = img_supports.shape
        query_repr = model(img_query)
        *_, h, w = query_repr.shape
        img_supports = rearrange(img_supports, 'b k n c h w -> (b k n) c h w', b=b)
        supports_repr = model(img_supports)
        query_q, query_v = (self.to_qk(query_repr), self.to_v(query_repr))
        supports_k, supports_v = (self.to_qk(supports_repr), self.to_v(supports_repr))
        supports_k, supports_v = map(lambda t: rearrange(t, '(b k n) c h w -> b k n c h w', b=b, k=k), (supports_k, supports_v))
        sim = einsum('b c h w, b k n c i j -> b k h w n i j', query_q, supports_k) * self.scale
        sim = rearrange(sim, 'b k h w n i j -> b k h w (n i j)')
        attn = sim.softmax(dim=-1)
        attn = rearrange(attn, 'b k h w (n i j) -> b k h w n i j', i=h, j=w)
        out = einsum('b k h w n i j, b k n c i j -> b k c h w', attn, supports_v)
        out = rearrange(out, 'b k c h w -> b k (c h w)')
        query_v = rearrange(query_v, 'b c h w -> b () (c h w)')
        euclidean_dist = ((query_v - out) ** 2).sum(dim=-1) / (h * w)
        return -euclidean_dist

INIT_ARGS = {
    'dim': 512,
    'dim_key': 128,
    'dim_value': 128,
}

ARGS = {
    'model': DummyModel(in_channels=3, out_channels=512),
    'img_query': torch.randn(2, 3, 4, 5),
    'img_supports': torch.randn(2, 3, 2, 3, 4, 5),
}

if __name__ == '__main__':
    cross_transformer = CrossTransformer(**INIT_ARGS)
    output = cross_transformer(**ARGS)
    print("Output shape:", output.shape)
    print("Output:", output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
einops, 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, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MetaTemplate Ran
ran on a synthesized input · constructed an object; no result was computed
vinuni-vishc/Few-Shot-Cosine-Transformer/methods/CTX.py
pointer only (licence: NOASSERTION) · get_code("44dc6d9430e110d2")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, vinuni-vishc/Few-Shot-Cosine-Transformer (NOASSERTION). 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.

gray_loader Ran
ran, honoured the contract we drafted
skrish13/CrossTransformers-PyTorch/dataset.py
code served (permissive licence) · get_code("d27f84ceb30afcc3")
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 Image. 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 os
import os.path as path
import json
import torch
import torch.utils.data as data
import numpy as np
import random
from PIL import Image
import pdb
import csv
import glob
import pandas as pd
import tempfile

# Create a temporary grayscale image file for testing
temp_dir = tempfile.mkdtemp()
temp_image_path = path.join(temp_dir, "test_image.png")

# Create a small grayscale image and save it
img = Image.new('L', (4, 3), color=128)
img.save(temp_image_path)

ARGS = {
    'path': temp_image_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL, numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 2 and dtype family int 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
pil_loader Ran
ran, honoured the contract we drafted
skrish13/CrossTransformers-PyTorch/dataset.py
code served (permissive licence) · get_code("8f03e823e1ea61e9")
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 Image. 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 os
import os.path as path
import json
import torch
import torch.utils.data as data
import numpy as np
import random
from PIL import Image
import pdb
import csv
import glob
import pandas as pd
import tempfile

def pil_loader(path):
    with open(path, 'rb') as f:
        with Image.open(f) as img:
            return img.convert('RGB')

# Create a temporary image file for testing
temp_dir = tempfile.mkdtemp()
temp_image_path = path.join(temp_dir, "test_image.png")

# Create a small RGB image and save it
test_image = Image.new('RGB', (4, 3), color=(255, 0, 0))
test_image.save(temp_image_path)

ARGS = {
    'path': temp_image_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL, numpy, pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
accimage_loader Not yet run
unverified (harvested, no recorded run)
skrish13/CrossTransformers-PyTorch/dataset.py
code served (permissive licence) · get_code("ab5055d91c86b111")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 4 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
accimage_loader 39 other papers
9 dated earlier, 30 later
1702.00758 (2017-02)
HashNet: Deep Learning to Hash by Continuation
1711.02512 (2017-11)
Fine-tuning CNN Image Retrieval with No Human Annotation
1805.00907 (2018-05)
Glow: Graph Lowering Compiler Techniques for Neural Networks
and 36 more not named here
pil_loader 28 other papers
10 dated earlier, 18 later
1702.00758 (2017-02)
HashNet: Deep Learning to Hash by Continuation
1805.07932 (2018-05)
Bilinear Attention Networks
1807.06587 (2018-07)
Deep Exemplar-based Colorization
and 25 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

Given new tasks with very little data-such as new classes in a classification problem or a domain shift in the input-performance of modern vision systems degrades remarkably quickly. In this work, we illustrate how the neural network representations which underpin modern vision systems are subject to supervision collapse, whereby they lose any information that is not necessary for performing the training task, including information that may be necessary for transfer to new tasks or domains. We then propose two methods to mitigate this problem. First, we employ self-supervised learning to encourage general-purpose features that transfer better. Second, we propose a novel Transformer based neural network architecture called CrossTransformers, which can take a small number of labeled images and an unlabeled query, find coarse spatial correspondence between the query and the labeled images, and then infer class membership by computing distances between spatially-corresponding features. The result is a classifier that is more robust to task and domain shift, which we demonstrate via state-of-theart performance on Meta-Dataset, a recent dataset for evaluating transfer from ImageNet to many other vision datasets. Code and pretrained checkpoints available at: https://github.com/google-research/meta-dataset.

For agents

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

get_harvested_code_for_paper("2007.11498")
get_code_for_paper("2007.11498")
have("2007.11498")

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

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

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

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

Connect an agent — have() is free.