SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1806.04321 · 2018

Energy-Constrained Compression for Deep Neural Networks via Weighted Sparse Projection and Layer Input Masking

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 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, 0 violated it and 6 have no contract verdict; 0 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/1806.04321.json · badge: /api/ran/1806.04321.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
hyang1990/model_based_energy_constrained_compression canonical (classifier label)
classifier basis: census
6 ran · 3 no recorded run
FunctionStatusWhere it lives
get_data_loaders Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/utils.py
code served (permissive licence) · get_code("274396f6683440b3")
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 torch
import os
import tempfile
from torch.utils.data import DataLoader, TensorDataset
from torchvision import transforms

torch.manual_seed(0)

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

# Create minimal fake ImageNet structure
train_dir = os.path.join(temp_dir, 'train')
val_dir = os.path.join(temp_dir, 'val')
os.makedirs(train_dir, exist_ok=True)
os.makedirs(val_dir, exist_ok=True)

# Create fake class directories with dummy images
for class_name in ['class0', 'class1']:
    os.makedirs(os.path.join(train_dir, class_name), exist_ok=True)
    os.makedirs(os.path.join(val_dir, class_name), exist_ok=True)
    
    # Create dummy image files
    from PIL import Image
    import numpy as np
    
    dummy_img = Image.fromarray(np.random.randint(0, 256, (224, 224, 3), dtype=np.uint8))
    
    # Create training images
    for i in range(2):
        dummy_img.save(os.path.join(train_dir, class_name, f'img_{i}.jpg'))
    
    # Create validation images
    for i in range(2):
        dummy_img.save(os.path.join(val_dir, class_name, f'img_{i}.jpg'))

ARGS = {
    'data_dir': temp_dir,
    'dataset': 'imagenet',
    'batch_size': 2,
    'val_batch_size': 2,
    'num_workers': 0,
    'nsubset': -1,
    'normalize': None,
}
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
getmask Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/proj_utils.py
code served (permissive licence) · get_code("45ac66d2e4695a84")
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 SimpleModel. 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
import copy

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.layer1(x)
        x = self.layer2(x)
        return x

model = SimpleModel()

# Sparsify the model by zeroing out some weights
with torch.no_grad():
    model.layer1.weight.data[0, 0] = 0.0
    model.layer1.weight.data[1, 1] = 0.0
    model.layer2.weight.data[0, 0] = 0.0

ARGS = {
    'model': model,
    'param_name': 'weight'
}
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 SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel 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
idx2mask Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/proj_utils.py
code served (permissive licence) · get_code("7ec9c962574311f4")
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 SimpleModel. 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 small model with named parameters ending in 'weight'
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer1 = nn.Linear(4, 3)
        self.layer2 = nn.Linear(3, 2)
    
    def forward(self, x):
        return self.layer2(self.layer1(x))

# Create mask_model instance
mask_model = SimpleModel()

# Create z_idx as a tensor of indices
# Total parameter count: layer1.weight (4*3=12) + layer1.bias (3) + layer2.weight (3*2=6) + layer2.bias (2) = 23
# Select some indices to zero out
z_idx = torch.tensor([2, 5, 8, 15, 18], dtype=torch.long)

# Build W_shapes list by collecting shapes of parameters ending in 'weight'
W_shapes = []
for name, W in mask_model.named_parameters():
    if name.endswith('weight'):
        W_shapes.append((name, W.shape))

# Define ARGS dictionary
ARGS = {
    'mask_model': mask_model,
    'z_idx': z_idx,
    'W_shapes': W_shapes,
    'param_name': 'weight'
}
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 SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel 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
model_mask Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/proj_utils.py
code served (permissive licence) · get_code("b06f8615a5095ca1")
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 SimpleModel. 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
import copy

torch.manual_seed(0)

# Create a simple model with weight parameters
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

# Instantiate the model
model = SimpleModel()

# Ensure the model has some non-zero weights
with torch.no_grad():
    model.linear1.weight.fill_(0.5)
    model.linear2.weight.fill_(0.3)

ARGS = {
    'model': model,
    'param_name': 'weight'
}
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 SimpleModel — a SimpleModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SimpleModel 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
ncorrect Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/utils.py
code served (permissive licence) · get_code("0381aca898cc3e77")
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 torch

torch.manual_seed(0)

# Create small tensors for testing
batch_size = 2
num_classes = 4

# output: model predictions, shape (batch_size, num_classes)
# The function calls output.topk(), so it needs to be a tensor
output = torch.randn(batch_size, num_classes)

# target: ground truth labels, shape (batch_size,)
# The function calls target.view(1, -1), so it needs to be a tensor
target = torch.tensor([0, 2])

# topk: tuple of k values to compute accuracy for
topk = (1, 2)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk,
}
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 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
reset_Xenergy_cache Ran
ran on a synthesized input
hyang1990/model_based_energy_constrained_compression/sa_energy_model.py
code served (permissive licence) · get_code("a45d056172896a3d")
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 dict. 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 a small stand-in class for layer energy info
class EnergyInfo:
    def __init__(self):
        self.cached_Xenergy = torch.randn(2, 4)  # Small tensor

# Build energy_info dict with multiple layers
energy_info = {
    "layer_1": EnergyInfo(),
    "layer_2": EnergyInfo(),
    "layer_3": EnergyInfo(),
}

# Verify that cached_Xenergy is not None before reset
assert energy_info["layer_1"].cached_Xenergy is not None
assert energy_info["layer_2"].cached_Xenergy is not None
assert energy_info["layer_3"].cached_Xenergy is not None

ARGS = {
    "energy_info": energy_info,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
build_energy_info Not yet run
unverified (harvested, no recorded run)
hyang1990/model_based_energy_constrained_compression/sa_energy_model.py
code served (permissive licence) · get_code("5012bf32b0b89865")
How it ran

no invocation recorded.

conv_cache_overlap Not yet run
unverified (harvested, no recorded run)
hyang1990/model_based_energy_constrained_compression/sa_energy_model.py
code served (permissive licence) · get_code("afc5712a48271ee9")
How it ran

no invocation recorded.

get_mnist32 Not yet run
unverified (harvested, no recorded run)
hyang1990/model_based_energy_constrained_compression/utils.py
code served (permissive licence) · get_code("b656a93047705838")
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, 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 9 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

Deep Neural Networks (DNNs) are increasingly deployed in highly energy-constrained environments such as autonomous drones and wearable devices while at the same time must operate in real-time. Therefore, reducing the energy consumption has become a major design consideration in DNN training. This paper proposes the first end-to-end DNN training framework that provides quantitative energy consumption guarantees via weighted sparse projection and input masking. The key idea is to formulate the DNN training as an optimization problem in which the energy budget imposes a previously unconsidered optimization constraint. We integrate the quantitative DNN energy estimation into the DNN training process to assist the constrained optimization. We prove that an approximate algorithm can be used to efficiently solve the optimization problem. Compared to the best prior energy-saving methods, our framework trains DNNs that provide higher accuracies under same or lower energy budgets. Code is publicly available.

For agents

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

get_harvested_code_for_paper("1806.04321")
get_code_for_paper("1806.04321")
have("1806.04321")

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

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

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

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

Connect an agent — have() is free.