SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.02306 · 2021

Connectivity Matters: Neural Network Pruning Through the Lens of Effective Sparsity

arXiv · PDF · Open in the Atlas

Code that ran

8 of 12 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 8 have no contract verdict; 0 failures of our instrument; 4 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/2107.02306.json · badge: /api/ran/2107.02306.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
avysogorets/effective-sparsity canonical (classifier label)
classifier basis: census
8 ran · 4 no recorded run
FunctionStatusWhere it lives
check_valid_sparsities Ran
ran on a synthesized input
avysogorets/effective-sparsity/utils.py
code served (permissive licence) · get_code("f5e1cacf2e574898")
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 1, dtype family float, shape (5,) 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
import logging

def check_valid_sparsities(sparsities):
    if sum([int(s <= 1 and s >= 0) for s in sparsities]) < len(sparsities):
        logging.error(f'<utils> invalid sparsities {sparsities} encountered.')
    assert sum([int(s <= 1 and s >= 0) for s in sparsities]) == len(sparsities), f'<utils> invalid sparsities {sparsities} encountered.'
    return np.array(sparsities)

# Valid sparsities: all values should be between 0 and 1 (inclusive)
ARGS = {
    "sparsities": [0.0, 0.5, 1.0, 0.3, 0.7]
}
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 1, dtype family float, shape (5,) — shape (5,) 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_annotations_map Ran
ran on a synthesized input
avysogorets/effective-sparsity/tinyimagenet.py
code served (permissive licence) · get_code("48d3eda95a1df7e6")
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 tempfile
import os

# Create a temporary directory structure with a val_annotations.txt file
temp_dir = tempfile.mkdtemp()
val_dir = os.path.join(temp_dir, 'val')
os.makedirs(val_dir, exist_ok=True)

# Create a sample annotations file
annotations_file_path = os.path.join(val_dir, 'val_annotations.txt')
with open(annotations_file_path, 'w') as f:
    f.write("image1.jpg class1\n")
    f.write("image2.jpg class2\n")
    f.write("image3.jpg class1\n")

ARGS = {
    'path': temp_dir
}
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 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
get_direct_sparsity Ran
ran on a synthesized input
avysogorets/effective-sparsity/utils.py
code served (permissive licence) · get_code("f1e8db189aa50a91")
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 1, dtype family float, shape (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 numpy as np

# Test case 1: Multiple sparse matrices
matrix1 = np.array([[1, 0, 0],
                    [0, 2, 0],
                    [0, 0, 3]], dtype=np.float32)

matrix2 = np.array([[4, 0, 0, 0],
                    [0, 5, 0, 0],
                    [0, 0, 6, 0]], dtype=np.float32)

matrix3 = np.array([[0, 0, 0, 0, 0],
                    [7, 0, 0, 0, 0],
                    [0, 8, 0, 0, 0],
                    [0, 0, 9, 0, 0]], dtype=np.float32)

matrices = [matrix1, matrix2, matrix3]

ARGS = {
    "matrices": matrices
}
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 1, dtype family float, shape (3,) — shape (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: none by the harness; any seed is in the setup block
get_overall_direct_sparsity Ran
ran on a synthesized input
avysogorets/effective-sparsity/utils.py
code served (permissive licence) · get_code("234d756014c461ba")
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 float64, ndim 0, 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 numpy as np

# Create small test matrices with different shapes for distinction
matrix1 = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0]], dtype=np.float32)  # 4x3, some zeros
matrix2 = np.array([[1, 2], [0, 3], [4, 0]], dtype=np.float32)  # 3x2, some zeros
matrix3 = np.random.randn(2, 5).astype(np.float32)  # 2x5, dense

matrices = [matrix1, matrix2, matrix3]

ARGS = {
    "matrices": matrices
}
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 float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
lamp Ran
ran on a synthesized input
avysogorets/effective-sparsity/pruning.py
code served (permissive licence) · get_code("2af6c0698e3e005a")
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 numpy as np

# The function expects:
# - weights: a list of numpy arrays (weight matrices)
# - target_sparsity: a float between 0 and 1

# Create some small weight matrices with distinct shapes
weight1 = np.random.randn(4, 3)
weight2 = np.random.randn(2, 5)
weight3 = np.random.randn(3, 2)

weights = [weight1, weight2, weight3]
target_sparsity = 0.5

ARGS = {
    "weights": weights,
    "target_sparsity": target_sparsity
}
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 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
load_images Ran
ran on a synthesized input
avysogorets/effective-sparsity/tinyimagenet.py
code served (permissive licence) · get_code("4ee899d1c4d39815")
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 os
import numpy as np
import tempfile
from PIL import Image

# Create a temporary directory structure that mimics the expected dataset layout
temp_dir = tempfile.mkdtemp()

# Create train directory structure
train_dir = os.path.join(temp_dir, 'train')
os.makedirs(train_dir)

# Create 2 classes for training
for class_idx in range(2):
    class_dir = os.path.join(train_dir, f'class_{class_idx}')
    images_dir = os.path.join(class_dir, 'images')
    os.makedirs(images_dir)
    
    # Create 5 dummy images per class (instead of 500 to keep it small)
    for img_idx in range(5):
        img = Image.new('RGB', (64, 64), color=(100 + class_idx * 50, 100, 100))
        img.save(os.path.join(images_dir, f'image_{img_idx}.png'))

# Create val directory structure
val_dir = os.path.join(temp_dir, 'val')
val_images_dir = os.path.join(val_dir, 'images')
os.makedirs(val_images_dir)

# Create val_annotations.txt
annotations_content = ""
for class_idx in range(2):
    for img_idx in range(5):
        img_name = f'val_image_{class_idx}_{img_idx}.png'
        class_name = f'class_{class_idx}'
        annotations_content += f"{img_name} {class_name}\n"
        
        # Create the actual validation images
        img = Image.new('RGB', (64, 64), color=(150 + class_idx * 50, 150, 150))
        img.save(os.path.join(val_images_dir, img_name))

with open(os.path.join(val_dir, 'val_annotations.txt'), 'w') as f:
    f.write(annotations_content)

ARGS = {
    'path': temp_dir,
    'num_classes': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — 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
magnitude_global Ran
ran on a synthesized input
avysogorets/effective-sparsity/pruning.py
code served (permissive licence) · get_code("29761fa5e5cfbad7")
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 numpy as np

# Create small weight matrices with distinct shapes
weight1 = np.random.randn(4, 3).astype(np.float32)
weight2 = np.random.randn(5, 2).astype(np.float32)
weight3 = np.random.randn(6,).astype(np.float32)

weights = [weight1, weight2, weight3]
target_sparsity = 0.5

ARGS = {
    "weights": weights,
    "target_sparsity": target_sparsity
}
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 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
magnitude_layerwise Ran
ran on a synthesized input
avysogorets/effective-sparsity/pruning.py
code served (permissive licence) · get_code("8e374b0bc371e7d3")
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 (4, 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 numpy as np

# Construct arguments for magnitude_layerwise function
# The function takes a weight array and target_sparsity float

# Create a small weight matrix (distinct dimensions: 4x3)
weight = np.random.randn(4, 3).astype(np.float32)

# Set target sparsity to 0.5 (prune 50% of weights)
target_sparsity = 0.5

ARGS = {
    "weight": weight,
    "target_sparsity": target_sparsity
}
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 (4, 3) — shape (4, 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: none by the harness; any seed is in the setup block
effective_masks_custom Not yet run
unverified (harvested, no recorded run)
avysogorets/effective-sparsity/effective_masks.py
code served (permissive licence) · get_code("388729982d8f315c")
How it ran

no invocation recorded.

get_data Not yet run
unverified (harvested, no recorded run)
avysogorets/effective-sparsity/data.py
code served (permissive licence) · get_code("515c5d29caa76c44")
How it ran

no invocation recorded.

get_model Not yet run
unverified (harvested, no recorded run)
avysogorets/effective-sparsity/models.py
code served (permissive licence) · get_code("3c8c6de0284222a8")
How it ran

no invocation recorded.

stabilizer_synflow_layer Not yet run
unverified (harvested, no recorded run)
avysogorets/effective-sparsity/effective_masks.py
code served (permissive licence) · get_code("62703c42dc5d39ab")
How it ran

no invocation recorded.

Also present in other papers' code

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

Neural network pruning is a fruitful area of research with surging interest in high sparsity regimes. Benchmarking in this domain heavily relies on faithful representation of the sparsity of subnetworks, which has been traditionally computed as the fraction of removed connections (direct sparsity). This definition, however, fails to recognize unpruned parameters that detached from input or output layers of underlying subnetworks, potentially underestimating actual effective sparsity: the fraction of inactivated connections. While this effect might be negligible for moderately pruned networks (up to 10-100 compression rates), we find that it plays an increasing role for thinner subnetworks, greatly distorting comparison between different pruning algorithms. For example, we show that effective compression of a randomly pruned LeNet-300-100 can be orders of magnitude larger than its direct counterpart, while no discrepancy is ever observed when using SynFlow for pruning [Tanaka et al., 2020]. In this work, we adopt the lens of effective sparsity to reevaluate several recent pruning algorithms on common benchmark architectures (e.g., LeNet-300-100, VGG-19, ResNet-18) and discover that their absolute and relative performance changes dramatically in this new and more appropriate framework. To aim for effective, rather than direct, sparsity, we develop a low-cost extension to most pruning algorithms. Further, equipped with effective sparsity as a reference frame, we partially reconfirm that random pruning with appropriate sparsity allocation across layers performs as well or better than more sophisticated algorithms for pruning at initialization [Su et al., 2020]. In response to this observation, using a simple analogy of pressure distribution in coupled cylinders from physics, we design novel layerwise sparsity quotas that outperform all existing baselines in the context of random pruning.

For agents

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

get_harvested_code_for_paper("2107.02306")
get_code_for_paper("2107.02306")
have("2107.02306")

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

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

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

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

Connect an agent — have() is free.