SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2003.11498 · 2020

Similarity of Neural Networks with Gradients

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 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 7 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/2003.11498.json · badge: /api/ran/2003.11498.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
marcozullich/pruned_layer_similarity community (classifier label)
classifier basis not recorded on the link
7 ran · 4 no recorded run
FunctionStatusWhere it lives
cka Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/nn_comparison.py
code served (permissive licence) · get_code("09d4486f337cf7b2")
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

torch.manual_seed(0)

# The function expects two kernel matrices (2D tensors)
# Kernel matrices are typically square and symmetric, but the function
# just needs tensors that support:
# - .mean(0), .mean(1), .mean() operations
# - @ (matrix multiplication)
# - .trace() method
# - .norm() method

kernel1 = torch.randn(4, 4)
kernel2 = torch.randn(4, 4)

ARGS = {
    "kernel1": kernel1,
    "kernel2": kernel2,
}
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
lf_mask_global Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/pruning/LF_mask.py
code served (permissive licence) · get_code("8ccbf4af2c43854c")
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
import numpy as np
from collections import OrderedDict as odict

torch.manual_seed(0)

# Create a minimal neural network with conv layers
class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 4, kernel_size=3)
        self.conv2 = nn.Conv2d(4, 8, kernel_size=3)
        self.fc = nn.Linear(8, 2)
    
    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        return x

net = SimpleNet()

ARGS = {
    'net': net,
    'pruning_factor': 0.2,
    'previous_mask': None,
    'layer_ids_to_prune': ['conv']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
mask_prop_params Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/pruning/LF_mask.py
code served (permissive licence) · get_code("58df0d7122e9d2e5")
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 float, 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 as nn

torch.manual_seed(0)

# Create a simple neural network
class SimpleNet(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

net = SimpleNet()

# Create a mask dict that matches some (but not all) keys in the state_dict
# The mask contains binary tensors indicating which parameters are kept (nonzero)
mask = {
    'layer1.weight': torch.ones(3, 4),  # all parameters kept
    'layer1.bias': torch.tensor([1.0, 0.0, 1.0]),  # partial mask
}

ARGS = {
    'mask': mask,
    'net': net
}
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 float, 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
n_dataloader Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/utils.py
code served (permissive licence) · get_code("84cff1784c0e138b")
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 torch
from torch.utils.data import DataLoader, TensorDataset

torch.manual_seed(0)

# Create a small dataset with 2 samples per batch, 3 batches total
# Input shape: (batch_size, 4), Target shape: (batch_size, 1)
inputs = torch.randn(7, 4)  # 7 samples total
targets = torch.randn(7, 1)

dataset = TensorDataset(inputs, targets)
dataloader = DataLoader(dataset, batch_size=2)

ARGS = {
    'dataloader': dataloader
}
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 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
reshape_4d_tensor Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/preprocessing.py
code served (permissive licence) · get_code("f248fd8826172f1e")
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 2, dtype family float, shape (2, 60) 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 as nn

torch.manual_seed(0)

# Create a small 4D tensor with distinct dimensions for easy probing
# Shape: (datapoints=2, channels=3, height=4, width=5)
tensor = torch.randn(2, 3, 4, 5)

ARGS = {
    "tensor": tensor,
    "neurons_are_channels": False,
}
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 2, dtype family float, shape (2, 60) — shape (2, 60) 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
svd_decomposition Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/preprocessing.py
code served (permissive licence) · get_code("a607b8da0ad72744")
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
import torch.nn as nn

torch.manual_seed(0)

# The function expects a 2D tensor with shape (datapoints, neurons)
# where datapoints > neurons
# It calls: .shape, .mean(0), subtraction/addition operations, .svd()
tensor = torch.randn(5, 3)  # 5 datapoints > 3 neurons

ARGS = {
    'tensor': tensor
}
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
svd_reduction Ran
ran on a synthesized input
marcozullich/pruned_layer_similarity/layer_sim/preprocessing.py
code served (permissive licence) · get_code("784c23f1bf771b6f")
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 2, dtype family float, shape (5, 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 torch
import numpy as np

torch.manual_seed(0)

# Create a 2D tensor with shape (batch=5, features=3)
# where batch (5) > features (3) to satisfy SVD requirements
tensor = torch.randn(5, 3, dtype=torch.float32)

ARGS = {
    'tensor': tensor,
    'var_fract_kept': 0.99
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (5, 3) — shape (5, 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
CIFAR10 Not yet run
unverified (harvested, no recorded run)
marcozullich/pruned_layer_similarity/layer_sim/datasets.py
code served (permissive licence) · get_code("c4a027ab6113a900")
How it ran

no invocation recorded.

MNIST Not yet run
unverified (harvested, no recorded run)
marcozullich/pruned_layer_similarity/layer_sim/datasets.py
code served (permissive licence) · get_code("15d4f21d63e777a0")
How it ran

no invocation recorded.

SVHN Not yet run
unverified (harvested, no recorded run)
marcozullich/pruned_layer_similarity/layer_sim/datasets.py
code served (permissive licence) · get_code("8db20ee6e093bb90")
How it ran

no invocation recorded.

nbs Not yet run
unverified (harvested, no recorded run)
marcozullich/pruned_layer_similarity/layer_sim/nn_comparison.py
code served (permissive licence) · get_code("68f669694231d8d9")
How it ran

no invocation recorded.

Also present in other papers' code

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

A suitable similarity index for comparing learnt neural networks plays an important role in understanding the behaviour of the highly-nonlinear functions, and can provide insights on further theoretical analysis and empirical studies. We define two key steps when comparing models: firstly, the representation abstracted from the learnt model, where we propose to leverage both feature vectors and gradient ones (which are largely ignored in prior work) into designing the representation of a neural network. Secondly, we define the employed similarity index which gives desired invariance properties, and we facilitate the chosen ones with sketching techniques for comparing various datasets efficiently. Empirically, we show that the proposed approach provides a state-of-the-art method for computing similarity of neural networks that are trained independently on different datasets and the tasks defined by the datasets.

For agents

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

get_harvested_code_for_paper("2003.11498")
get_code_for_paper("2003.11498")
have("2003.11498")

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

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

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

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

Connect an agent — have() is free.