SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.08322 · CVPR · 2021

Dynamic Head: Unifying Object Detection Heads with Attentions

Lei Zhang, Lu Yuan, Xiyang Dai, Chen Liu, Microsoft Redmond, Yinpeng Bin, Xiao Dongdong

arXiv · PDF · Open in the Atlas

Code that ran

8 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 3 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/2106.08322.json · badge: /api/ran/2106.08322.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/DynamicHead canonical (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
Coldestadam/DynamicHead community
Papers with Code archive
5 ran · 1 no recorded run
FunctionStatusWhere it lives
DyHead_Block Ran
ran on a synthesized input · constructed an object; no result was computed
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("43a848f530c2b68c")
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, DyHead_Block: 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 torch.nn as nn
from torchvision.ops import DeformConv2d

torch.manual_seed(0)

# Parameters for DyHead_Block
L = 64  # L_size
S = 32  # S_size
C = 16  # C_size (num_channels)

ARGS = {
    'L': L,
    'S': S,
    'C': C
}
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 DyHead_Block — 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 DyHead_Block 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
DyReLUA Ran
ran on a synthesized input · constructed an object; no result was computed
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("f1f13347d3ea0492")
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, DyReLUA: 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 torch.nn as nn

torch.manual_seed(0)

# Analyze what DyReLUA.__init__ needs:
# - channels: int (used in Linear layers and tensor operations)
# - reduction: int (default 8, used for channels // reduction)
# - k: int (default 2, used for 2*k in fc2 output)
# - lambdas: optional tensor (shape should match init_values, which is [2*k])
# - init_values: optional tensor (shape should match lambdas, which is [2*k])

# Analyze what forward needs:
# - F_tensor: shape (batch, channels, height, width) for 4D conv output
# - Uses kernel_size = F_tensor.shape[2:] for avg_pool2d
# - gap_output flattened to (batch, channels)
# - fc1 expects channels input, outputs channels//reduction
# - fc2 expects channels//reduction input, outputs 2*k
# - theta indexing with theta[0, :2] and theta[0, 2:] means theta needs shape (batch, 2*k)
# - alphas and betas each have 2 elements (for k=2)
# - Output computed with alphas[0], alphas[1], betas[0], betas[1]

channels = 8
reduction = 2
k = 2

# Create lambdas and init_values tensors
# They should have shape (2*k,) = (4,)
lambdas = torch.tensor([1.0, 1.0, 0.5, 0.5], dtype=torch.float)
init_values = torch.tensor([1.0, 0.0, 0.0, 0.0], dtype=torch.float)

# Create input tensor: (batch=2, channels=8, height=4, width=3)
# Using distinct dimensions for clarity
F_tensor = torch.randn(2, channels, 4, 3)

ARGS = {
    'channels': channels,
    'reduction': reduction,
    'k': k,
    'lambdas': lambdas,
    'init_values': init_values
}
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 DyReLUA — 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 DyReLUA 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
Scale_Aware_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("ae71a995161d732d")
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, Scale_Aware_Layer: 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 torch.nn as nn

torch.manual_seed(0)

class Scale_Aware_Layer(nn.Module):

    def __init__(self, s_size):
        super(Scale_Aware_Layer, self).__init__()
        self.avg_layer = nn.AvgPool2d(kernel_size=3, stride=1, padding=1)
        self.conv = nn.Conv2d(in_channels=s_size, out_channels=1, kernel_size=1)
        self.hard_sigmoid = nn.Hardsigmoid()
        self.relu = nn.ReLU()

    def forward(self, F):
        x = F.transpose(dim0=2, dim1=1)
        x = self.avg_layer(x)
        x = self.conv(x)
        x = x.transpose(dim0=1, dim1=2)
        x = self.relu(x)
        pi_L = self.hard_sigmoid(x)
        return pi_L * F

# Create an instance of Scale_Aware_Layer
s_size = 4
model = Scale_Aware_Layer(s_size)

# Create a sample input tensor with shape (batch=2, channels=4, height=3, width=5)
# The forward method expects a 4D tensor and will transpose it
input_tensor = torch.randn(2, 4, 3, 5)

ARGS = {
    "s_size": s_size
}
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 Scale_Aware_Layer — 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 Scale_Aware_Layer 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
Spatial_Aware_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("0d6fb3b73f74caa3")
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, Spatial_Aware_Layer: 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 torch.nn as nn
from torchvision.ops import DeformConv2d

torch.manual_seed(0)

# Create a small input tensor for testing
# Shape: (batch=2, channels=4, height=8, width=8)
input_tensor = torch.randn(2, 4, 8, 8)

ARGS = {
    'L_size': 4,
    'kernel_height': 3,
    'kernel_width': 3,
    'padding': 1,
    'stride': 1,
    'dilation': 1,
    'groups': 1
}

# Verify the setup by instantiating and running forward pass
if __name__ == '__main__':
    from torch_setup import Spatial_Aware_Layer
    layer = Spatial_Aware_Layer(**ARGS)
    output = layer(input_tensor)
    print(f"Input shape: {input_tensor.shape}")
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_setup, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Spatial_Aware_Layer — 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 Spatial_Aware_Layer 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
Task_Aware_Layer Ran
ran on a synthesized input · constructed an object; no result was computed
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("4c367c8f60b22fe0")
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, Task_Aware_Layer: 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 torch.nn as nn

torch.manual_seed(0)

# Task_Aware_Layer takes num_channels as its only parameter
# Looking at the forward method, it expects F_tensor with shape (batch, height, width, channels)
# where channels = num_channels
# The forward permutes to (batch, channels, height, width) for the dynamic_relu

num_channels = 4
batch_size = 2
height = 3
width = 5

ARGS = {
    "num_channels": num_channels
}
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 Task_Aware_Layer — 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 Task_Aware_Layer 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
permute_and_flatten Ran
ran; our contract draft was wrong, not the code
microsoft/DynamicHead/extra/atss.py
code served (permissive licence) · get_code("2028ba00ac3a78ae")
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 3, dtype family float, shape (2, 90, 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

torch.manual_seed(0)

# Construct arguments for permute_and_flatten
# The function expects:
# - layer: a tensor that will be reshaped to (N, -1, C, H, W)
# - N: batch size
# - A: second dimension after reshape (the -1 in view)
# - C: channels
# - H: height
# - W: width

N = 2
A = 3
C = 4
H = 5
W = 6

# Create a tensor with total elements = N * A * C * H * W
# This will be reshaped to (N, -1, C, H, W) where -1 becomes A
total_elements = N * A * C * H * W
layer = torch.randn(total_elements)

ARGS = {
    "layer": layer,
    "N": N,
    "A": A,
    "C": C,
    "H": H,
    "W": W
}
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 3, dtype family float, shape (2, 90, 4) — shape (2, 90, 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
window_partition Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
microsoft/DynamicHead/extra/swint.py
code served (permissive licence) · get_code("f9fd6241d935f07b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (12, 4, 4, 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

torch.manual_seed(0)

# Create a tensor with shape (B, H, W, C)
# B = 2 (batch size)
# H = 8 (height, must be divisible by window_size)
# W = 12 (width, must be divisible by window_size)
# C = 4 (channels)
# window_size = 4

B = 2
H = 8
W = 12
C = 4
window_size = 4

x = torch.randn(B, H, W, C)

ARGS = {
    'x': x,
    'window_size': window_size
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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 4, dtype family float, shape (12, 4, 4, 4) — shape (12, 4, 4, 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
window_reverse Ran
ran; our contract draft was wrong, not the code
microsoft/DynamicHead/extra/swint.py
code served (permissive licence) · get_code("fb32094c6dbece71")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Tensor, ndim 4, dtype family float, shape (2, 8, 12, 6) 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

torch.manual_seed(0)

# Define parameters
# We need windows of shape (num_windows*B, window_size, window_size, C)
# where num_windows = (H // window_size) * (W // window_size)

B = 2
H = 8
W = 12
window_size = 4
C = 6

# Calculate num_windows
num_windows_h = H // window_size  # 8 // 4 = 2
num_windows_w = W // window_size  # 12 // 4 = 3
num_windows = num_windows_h * num_windows_w  # 2 * 3 = 6

# Total number of windows across batch
total_windows = num_windows * B  # 6 * 2 = 12

# Create windows tensor
windows = torch.randn(total_windows, window_size, window_size, C)

ARGS = {
    'windows': windows,
    'window_size': window_size,
    'H': H,
    'W': W
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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 4, dtype family float, shape (2, 8, 12, 6) — shape (2, 8, 12, 6) 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
DyHead Not yet run
unverified (harvested, no recorded run)
Coldestadam/DynamicHead/torch/DyHead.py
code served (permissive licence) · get_code("0b96184174adb44f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 2 the same month, 3 later) and 6 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
window_reverse 227 other papers
6 dated earlier, 7 the same month, 214 later · 34 only as an assembly brick
1608.03983 (2016-08)
SGDR: Stochastic Gradient Descent with Warm Restarts
1711.10925 (2017-11)
Deep Image Prior
2003.13678 (2020-03)
Designing Network Design Spaces
and 224 more not named here
window_partition 223 other papers
6 dated earlier, 7 the same month, 210 later · 32 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1711.10925 (2017-11)
Deep Image Prior
2003.13678 (2020-03)
Designing Network Design Spaces
and 220 more not named here
permute_and_flatten 3 other papers
1 dated earlier, 2 later
1506.01497 (2015-06)
Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
2107.10064 (2021-07)
Few Shots Are All You Need: A Progressive Few Shot Learning Approach for Low Resource Handwritten Text Recognition
Guo_Knowledge_Distillation_for_6D_Pose_Estimation_by_Aligning_Distributions_of_CVPR_2023_paper (2023 (year only))
Knowledge Distillation for 6D Pose Estimation by Aligning Distributions of Local Predictions

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

The complex nature of combining localization and classification in object detection has resulted in the flourished development of methods. Previous works tried to improve the performance in various object detection heads but failed to present a unified view. In this paper, we present a novel dynamic head framework to unify object detection heads with attentions. By coherently combining multiple self-attention mechanisms between feature levels for scaleawareness, among spatial locations for spatial-awareness, and within output channels for task-awareness, the proposed approach significantly improves the representation ability of object detection heads without any computational overhead. Further experiments demonstrate that the effectiveness and efficiency of the proposed dynamic head on the COCO benchmark. With a standard ResNeXt-101-DCN backbone, we largely improve the performance over popular object detectors and achieve a new state-of-the-art at 54.0 AP. The code will be released at https://github. com/microsoft/DynamicHead.

For agents

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

get_harvested_code_for_paper("2106.08322")
get_code_for_paper("2106.08322")
have("2106.08322")

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

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

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

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

Connect an agent — have() is free.