SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1606.06160 · 2016

DoReFa-Net: Training Low Bitwidth Convolutional Neural Networks with Low Bitwidth Gradients

arXiv · PDF · Open in the Atlas

Code that ran

8 of 13 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; 1 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 5 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/1606.06160.json · badge: /api/ran/1606.06160.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
zzzxxxttt/Pytorch_DoReFaNet community (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
Xilinx/QNN-MO-PYNQ community (classifier label)
classifier basis not recorded on the link
1 ran · 2 no recorded run
mohdumar644/DoReFaNet-PyTorch reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
Enderdead/Pytorch_Quantize_impls community (classifier label)
classifier basis not recorded on the link
0 ran · 2 no recorded run
FunctionStatusWhere it lives
Binarize Ran
ran, honoured the contract we drafted
mohdumar644/DoReFaNet-PyTorch/dorefa.py
pointer only (licence: NONE) · get_code("9b288b4b39df6ef0")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, mohdumar644/DoReFaNet-PyTorch 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.

cifar_transform Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/utils/preprocessing.py
code served (permissive licence) · get_code("eae55d588689f5b0")
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 Compose. 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 torchvision.transforms as transforms
from PIL import Image
import numpy as np

torch.manual_seed(0)

# The function cifar_transform takes one parameter: is_training (boolean)
# It returns a transforms.Compose object that can be applied to images
# The function doesn't actually use the returned transform in its body,
# it just constructs and returns it.

ARGS = {
    'is_training': True
}
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 Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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_Q_fn Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/utils/quant_dorefa.py
code served (permissive licence) · get_code("83dd0e0d9e8ff52c")
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 type. 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)

# conv2d_Q_fn only takes one parameter: w_bit
# We'll test with a valid w_bit value (1, 2-8, or 32)

ARGS = {
    'w_bit': 4
}
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 type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
imageToColumn Ran
ran on a synthesized input
Xilinx/QNN-MO-PYNQ/qnn/utils.py
code served (permissive licence) · get_code("5807a473e81d05db")
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 ndarray, ndim 2, dtype family float, shape (18, 50) 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 numpy as np

# Create a small batch of images
# imageShape should be (batch_size, channels, height, width)
# Using distinct sizes: batch=2, channels=3, height=5, width=4
image = np.random.randn(2, 3, 5, 4).astype(np.float32)

# Define kernel dimensions
kernelHeight = 3
kernelWidth = 2

# Define padding and stride
padding = 1
stride = 1

ARGS = {
    "image": image,
    "kernelHeight": kernelHeight,
    "kernelWidth": kernelWidth,
    "padding": padding,
    "stride": stride,
}
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 ndarray, ndim 2, dtype family float, shape (18, 50) — shape (18, 50) 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
imgnet_transform Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/utils/preprocessing.py
code served (permissive licence) · get_code("2a3eccf3107517a4")
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 Compose. 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 torchvision.transforms as transforms
from PIL import Image
import numpy as np

torch.manual_seed(0)

ARGS = {
    "is_training": True
}
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 Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
linear_Q_fn Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/utils/quant_dorefa.py
code served (permissive licence) · get_code("9418f08dc30f8802")
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 type. 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 torch.nn.functional as F

torch.manual_seed(0)

def uniform_quantize(k):

    class qfn(torch.autograd.Function):

        @staticmethod
        def forward(ctx, input):
            if k == 32:
                out = input
            elif k == 1:
                out = torch.sign(input)
            else:
                n = float(2 ** k - 1)
                out = torch.round(input * n) / n
            return out

        @staticmethod
        def backward(ctx, grad_output):
            grad_input = grad_output.clone()
            return grad_input
    return qfn().apply

class weight_quantize_fn(nn.Module):

    def __init__(self, w_bit):
        super(weight_quantize_fn, self).__init__()
        assert w_bit <= 8 or w_bit == 32
        self.w_bit = w_bit
        self.uniform_q = uniform_quantize(k=w_bit)

    def forward(self, x):
        if self.w_bit == 32:
            weight_q = x
        elif self.w_bit == 1:
            E = torch.mean(torch.abs(x)).detach()
            weight_q = self.uniform_q(x / E) * E
        else:
            weight = torch.tanh(x)
            max_w = torch.max(torch.abs(weight)).detach()
            weight = weight / 2 / max_w + 0.5
            weight_q = max_w * (2 * self.uniform_q(weight) - 1)
        return weight_q

def linear_Q_fn(w_bit):

    class Linear_Q(nn.Linear):

        def __init__(self, in_features, out_features, bias=True):
            super(Linear_Q, self).__init__(in_features, out_features, bias)
            self.w_bit = w_bit
            self.quantize_fn = weight_quantize_fn(w_bit=w_bit)

        def forward(self, input):
            weight_q = self.quantize_fn(self.weight)
            return F.linear(input, weight_q, self.bias)
    return Linear_Q

ARGS = {
    'w_bit': 8
}
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 type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
resnet56 Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/nets/cifar_resnet.py
code served (permissive licence) · get_code("782db452fa8e9972")
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 PreActResNet. 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)

# Mock the quantization functions used by PreActBlock_conv_Q
def conv2d_Q_fn(w_bit):
    """Returns a Conv2d class with quantization applied."""
    class Conv2d_Q(nn.Conv2d):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)
    return Conv2d_Q

def activation_quantize_fn(a_bit):
    """Returns an activation quantization function."""
    def quantize(x):
        return x
    return quantize

# Make these available in the module namespace
import sys
current_module = sys.modules[__name__]
current_module.conv2d_Q_fn = conv2d_Q_fn
current_module.activation_quantize_fn = activation_quantize_fn

ARGS = {
    "wbits": 8,
    "abits": 8,
    "num_classes": 10,
}
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 PreActResNet — a PreActResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PreActResNet 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
uniform_quantize Ran
ran on a synthesized input
zzzxxxttt/Pytorch_DoReFaNet/utils/quant_dorefa.py
code served (permissive licence) · get_code("caf68e4b8567c88a")
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 method. 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)

# The function 'uniform_quantize' takes a single parameter 'k'
# which is used to control the quantization bit-width in the forward pass.
# The returned function expects a tensor input.

# We'll test with k=8 (a typical bit-width, not 32 or 1)
k = 8

# Create a small test input tensor
input_tensor = torch.randn(2, 4)

ARGS = {
    'k': k
}
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 method — a method output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a method 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
columnToImage Not yet run
unverified (harvested, no recorded run)
Xilinx/QNN-MO-PYNQ/qnn/utils.py
code served (permissive licence) · get_code("1c0993dfa6267ca3")
How it ran

no invocation recorded.

conv_layer Not yet run
unverified (harvested, no recorded run)
Xilinx/QNN-MO-PYNQ/qnn/utils.py
code served (permissive licence) · get_code("eb32c61d9c2ced17")
How it ran

no invocation recorded.

dataframe_filter Not yet run
unverified (harvested, no recorded run)
Enderdead/Pytorch_Quantize_impls/QuantTorch/compress.1.py
code served (permissive licence) · get_code("69deb4957901ff4f")
How it ran

no invocation recorded.

filter_fails Not yet run
unverified (harvested, no recorded run)
Enderdead/Pytorch_Quantize_impls/QuantTorch/compress.py
code served (permissive licence) · get_code("540d4c98feceae53")
How it ran

no invocation recorded.

resnet20 Not yet run
unverified (harvested, no recorded run)
zzzxxxttt/Pytorch_DoReFaNet/nets/cifar_resnet.py
code served (permissive licence) · get_code("ce5d6e10ff074840")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 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 13 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

We propose DoReFa-Net, a method to train convolutional neural networks that have low bitwidth weights and activations using low bitwidth parameter gradients. In particular, during backward pass, parameter gradients are stochastically quantized to low bitwidth numbers before being propagated to convolutional layers. As convolutions during forward/backward passes can now operate on low bitwidth weights and activations/gradients respectively, DoReFa-Net can use bit convolution kernels to accelerate both training and inference. Moreover, as bit convolutions can be efficiently implemented on CPU, FPGA, ASIC and GPU, DoReFa-Net opens the way to accelerate training of low bitwidth neural network on these hardware. Our experiments on SVHN and ImageNet datasets prove that DoReFa-Net can achieve comparable prediction accuracy as 32-bit counterparts. For example, a DoReFa-Net derived from AlexNet that has 1-bit weights, 2-bit activations, can be trained from scratch using 6-bit gradients to get 46.1\% top-1 accuracy on ImageNet validation set. The DoReFa-Net AlexNet model is released publicly.

For agents

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

get_harvested_code_for_paper("1606.06160")
get_code_for_paper("1606.06160")
have("1606.06160")

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

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

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

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

Connect an agent — have() is free.