SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper · ICCV · 2021

Dynamic Dual Gating Neural Networks

Gang Li, Xiangyu He, Jian Cheng, Fanrong Li

Open in the Atlas

Code that ran

9 of 10 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; 0 honoured the contract we drafted, 1 violated it and 5 have no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-23; 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/Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper.json · badge: /api/ran/Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper.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
lfr-0531/DGNet canonical (classifier label)
classifier basis: census
9 ran · 1 no recorded run
FunctionStatusWhere it lives
analyse_flops Ran
ran on a synthesized input
lfr-0531/DGNet/utils/misc.py
code served (permissive licence) · get_code("1fd8b2c1186ed427")
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 tuple. 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

torch.manual_seed(0)

# Analyzing the function:
# - flops_real is indexed as flops_real[0], flops_real[1], flops_real[2]
#   and flops_real[0] is indexed as block_flops[0:batch_size, :]
#   So flops_real should be a list/tuple of 3 tensors
# - flops_real[0] (block_flops) needs shape (at least batch_size, some_dim)
# - flops_mask is called with .mean(0) so it's a tensor
# - flops_ori is called with .mean(0) so it's a tensor
# - batch_size is an integer used for slicing

batch_size = 2

# flops_real is a tuple of 3 tensors
# block_flops should have at least batch_size rows
block_flops = torch.randn(4, 3)  # (4, 3) - enough rows for batch_size=2
flops_conv1 = torch.randn(5)      # arbitrary shape
flops_fc = torch.randn(6)         # arbitrary shape
flops_real = (block_flops, flops_conv1, flops_fc)

# flops_mask: tensor that can be meaned over dimension 0
flops_mask = torch.randn(7, 3)

# flops_ori: tensor that can be meaned over dimension 0
flops_ori = torch.randn(8, 3)

ARGS = {
    "flops_real": flops_real,
    "flops_mask": flops_mask,
    "flops_ori": flops_ori,
    "batch_size": batch_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 tuple — a tuple 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
conv1x1 Ran
ran; our contract draft was wrong, not the code
lfr-0531/DGNet/models/cifar/resdg.py
code served (permissive licence) · get_code("d9def42110729a85")
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 Conv2d. 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 conv1x1 takes in_planes, out_planes, and stride as parameters
# It returns an nn.Conv2d layer configured for 1x1 convolution
# We need to provide valid integer arguments for these parameters

ARGS = {
    "in_planes": 3,
    "out_planes": 64,
    "stride": 1
}
Setup block drafted by
a language model, Claude Haiku 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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
conv2d_out_dim Ran
ran on a synthesized input
lfr-0531/DGNet/models/cifar/resdg.py
code served (permissive licence) · get_code("fdc334fce5147261")
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 math

def conv2d_out_dim(dim, kernel_size, padding=0, stride=1, dilation=1, ceil_mode=False):
    if ceil_mode:
        return int(math.ceil((dim + 2 * padding - dilation * (kernel_size - 1) - 1) / stride + 1))
    else:
        return int(math.floor((dim + 2 * padding - dilation * (kernel_size - 1) - 1) / stride + 1))

ARGS = {
    "dim": 32,
    "kernel_size": 3,
    "padding": 1,
    "stride": 1,
    "dilation": 1,
    "ceil_mode": False
}
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
conv3x3 Ran
ran; our contract draft was wrong, not the code
lfr-0531/DGNet/models/cifar/resdg.py
code served (permissive licence) · get_code("160bb14bd76201b4")
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 Conv2d. 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)

ARGS = {
    "in_planes": 3,
    "out_planes": 64,
    "stride": 1,
    "groups": 1,
    "dilation": 1,
}
Setup block drafted by
a language model, Claude Haiku 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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
getDataLoader Ran
ran on a synthesized input
lfr-0531/DGNet/dataloader.py
code served (permissive licence) · get_code("6a0d39dc9d42740a")
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 tuple, ndim 1, 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 os
import tempfile
import torch
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from unittest.mock import Mock, MagicMock
import logging

torch.manual_seed(0)
logging.basicConfig(level=logging.INFO)

# Create a temporary directory for data
tmpdir = tempfile.mkdtemp()

# For CIFAR datasets, we need to mock the dataset since download=False
# Create mock CIFAR10 and CIFAR100 datasets
class MockCIFAR10(datasets.CIFAR10):
    def __init__(self, root, train=True, download=False, transform=None):
        self.root = root
        self.train = train
        self.transform = transform
        self.data = torch.randint(0, 256, (4, 32, 32, 3), dtype=torch.uint8).numpy()
        self.targets = torch.randint(0, 10, (4,)).tolist()
    
    def __getitem__(self, index):
        img = self.data[index]
        target = self.targets[index]
        if self.transform:
            from PIL import Image
            img = Image.fromarray(img)
            img = self.transform(img)
        return img, target
    
    def __len__(self):
        return len(self.targets)

class MockCIFAR100(datasets.CIFAR100):
    def __init__(self, root, train=True, download=False, transform=None):
        self.root = root
        self.train = train
        self.transform = transform
        self.data = torch.randint(0, 256, (4, 32, 32, 3), dtype=torch.uint8).numpy()
        self.targets = torch.randint(0, 100, (4,)).tolist()
    
    def __getitem__(self, index):
        img = self.data[index]
        target = self.targets[index]
        if self.transform:
            from PIL import Image
            img = Image.fromarray(img)
            img = self.transform(img)
        return img, target
    
    def __len__(self):
        return len(self.targets)

# Patch the datasets module
original_cifar10 = datasets.CIFAR10
original_cifar100 = datasets.CIFAR100
datasets.CIFAR10 = MockCIFAR10
datasets.CIFAR100 = MockCIFAR100

# Create mock ImageFolder dataset
class MockImageFolder(datasets.ImageFolder):
    def __init__(self, root, transform=None):
        self.root = root
        self.transform = transform
        self.samples = [(f"img_{i}", i % 1000) for i in range(4)]
        self.imgs = self.samples
        self.classes = [str(i) for i in range(1000)]
        self.class_to_idx = {c: int(c) for c in self.classes}
    
    def __getitem__(self, index):
        from PIL import Image
        import numpy as np
        img_array = np.random.randint(0, 256, (224, 224, 3), dtype=np.uint8)
        img = Image.fromarray(img_array)
        target = index % 1000
        if self.transform:
            img = self.transform(img)
        return img, target
    
    def __len__(self):
        return len(self.samples)

original_imagefolder = datasets.ImageFolder
datasets.ImageFolder = MockImageFolder

ARGS = {
    "data": tmpdir,
    "dataset": "cifar10",
    "batch_size": 2,
    "workers": 0,
}
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 tuple, ndim 1, dtype family float — a tuple 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_bloss_basic Ran
ran on a synthesized input
lfr-0531/DGNet/regularization.py
code served (permissive licence) · get_code("f3b60151e1cfdb2e")
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, 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.functional as F

torch.manual_seed(0)

# Analyze the function:
# - spar: used in arithmetic operations (relu, subtraction, etc.), should be a tensor
# - spar_tar: used in arithmetic operations, should be a tensor
# - batch_size: not directly used in the function body (parameter but unused)
# - gamma: scalar multiplier
# - p: scalar used in arithmetic operations

# Create small tensors for spar and spar_tar
# Shape: (batch_size,) or (batch_size, features)
# Using batch_size=2 and some feature dimension
spar = torch.randn(2, 4)
spar_tar = torch.randn(2, 4)

batch_size = 2
gamma = 0.5
p = 0.3

ARGS = {
    'spar': spar,
    'spar_tar': spar_tar,
    'batch_size': batch_size,
    'gamma': gamma,
    'p': p
}
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, 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
get_loggers Ran
ran on a synthesized input
lfr-0531/DGNet/utils/logger.py
code served (permissive licence) · get_code("ee56df29ce76ee59")
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 tuple, ndim 1, 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 os
import tempfile
import shutil

class Args:
    """Minimal args class with required attributes for get_loggers"""
    def __init__(self):
        self.checkpoint = ''
        self.arch = 'resnet50'
    
    def items(self):
        """Allow iteration over attributes like a dict"""
        return vars(self).items()

# Create a temporary directory for logs to avoid cluttering the filesystem
temp_dir = tempfile.mkdtemp()
original_cwd = os.getcwd()
os.chdir(temp_dir)

try:
    ARGS = {
        'args': Args()
    }
finally:
    # Clean up will happen after execution
    pass
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple 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
has_children Ran
ran, violated the contract we drafted
lfr-0531/DGNet/utils/logger.py
pointer only (licence: MIT); the stored copy get_code serves, from mrusci/training-mixed-precision-quantized-networks, is pointer only (licence: NONE) · get_code("ca5a147b43f9a328")
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 mrusci/training-mixed-precision-quantized-networks, 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.

plot_overlap Ran
ran; our contract draft was wrong, not the code
lfr-0531/DGNet/utils/logger.py
code served (permissive licence) · get_code("093c9b30736e13f4")
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 1, 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 matplotlib.pyplot as plt
import numpy as np

class MockLogger:
    def __init__(self):
        self.title = "test_plot"
        self.names = ["loss", "accuracy", "f1_score"]
        self.numbers = {
            "loss": [0.5, 0.4, 0.3, 0.2],
            "accuracy": [0.6, 0.7, 0.75, 0.8],
            "f1_score": [0.55, 0.68, 0.72, 0.78]
        }

logger = MockLogger()

ARGS = {
    "logger": logger,
    "names": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, 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
accuracy Not yet run
unverified (harvested, no recorded run)
lfr-0531/DGNet/utils/misc.py
code served (permissive licence) · get_code("f0c9a29156911331")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 4 later) and 5 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
conv1x1 431 other papers
106 dated earlier, 263 later, 61 same year, order not determinable, 1 undated · 38 only as an assembly brick
1409.1556 (2014-09)
Very Deep Convolutional Networks for Large-Scale Image Recognition
1506.01186 (2015-06)
Cyclical Learning Rates for Training Neural Networks
1507.05717 (2015-07)
An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition
and 428 more not named here
conv3x3 312 other papers
61 dated earlier, 209 later, 41 same year, order not determinable, 1 undated · 31 only as an assembly brick
1409.1556 (2014-09)
Very Deep Convolutional Networks for Large-Scale Image Recognition
1507.05717 (2015-07)
An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
and 309 more not named here
accuracy 71 other papers
43 dated earlier, 16 later, 12 same year, order not determinable · 2 only as an assembly brick
1505.05424 (2015-05)
Weight Uncertainty in Neural Networks
1705.07204 (2017-05)
Ensemble Adversarial Training: Attacks and Defenses
1802.10399 (2018-02)
Compressing Neural Networks using the Variational Information Bottleneck
and 68 more not named here
plot_overlap 2 other papers
1 dated earlier, 1 later
1611.05431 (2016-11)
Aggregated Residual Transformations for Deep Neural Networks
2210.15318 (2022-10)
Efficient and Effective Augmentation Strategy for Adversarial Training
has_children 1 other paper
1 dated earlier
1905.13082 (2019-05)
Memory-Driven Mixed Low Precision Quantization For Enabling Deep Network Inference On Microcontrollers

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-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In dynamic neural networks that adapt computations to different inputs, gating-based methods have demonstrated notable generality and applicability in trading-off the model complexity and accuracy. However, existing works only explore the redundancy from a single point of the network, limiting the performance. In this paper, we propose dual gating, a new dynamic computing method, to reduce the model complexity at run-time. For each convolutional block, dual gating identifies the informative features along two separate dimensions, spatial and channel. Specifically, the spatial gating module estimates which areas are essential, and the channel gating module predicts the salient channels that contribute more to the results. Then the computation of both unimportant regions and irrelevant channels can be skipped dynamically during inference. Extensive experiments on a variety of datasets demonstrate that our method can achieve higher accuracy under similar computing budgets compared with other dynamic execution methods. In particular, dynamic dual gating can provide 59.7% saving in computing of ResNet50 with 76.41% top-1 accuracy on ImageNet, which has advanced the state-of-the-art. Codes are available at https: //github.com/lfr-0531/DGNet.

For agents

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

get_harvested_code_for_paper("Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper")
get_code_for_paper("Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper")
have("Li_Dynamic_Dual_Gating_Neural_Networks_ICCV_2021_paper")

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

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

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

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

Connect an agent — have() is free.