SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.12794 · ICML · 2024

Expand-and-Cluster: Parameter Recovery of Neural Networks

Wulfram Gerstner, Johanni Brea, Flavio Martinelli, Berfin ¸ims ¸ek

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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 0 have no contract verdict; 5 failures of our instrument; 2 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/2304.12794.json · badge: /api/ran/2304.12794.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
flavio-martinelli/expand-and-cluster canonical (classifier label)
classifier basis: classifier_2025
5 ran · 2 no recorded run
FunctionStatusWhere it lives
collapse Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("b9f16dd9c3dd796b")
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

# Set seed for reproducibility
np.random.seed(0)

# Parameters based on function signature and usage:
# - clusters: list of arrays containing neuron indices
# - cluster_indices: list of arrays with indices into clusters
# - W: weight matrix of shape (input_dim, fan_out, num_nets)
# - A: activation matrix of shape (fan_out, output_dim, num_nets) or None
# - N: number of networks (scalar)
# - losses: array of loss values
# - fan_out: neurons per network (scalar)
# - final_layer: boolean indicating if this is final layer
# - original_signs: array of signs for each neuron
# - symmetry: string indicating symmetry type ('odd', 'odd_constant', or other)
# - verbose: boolean for printing

# Build minimal valid arguments
fan_out = 3
num_nets = 2
input_dim = 4
output_dim = 5
N = num_nets

# W: shape (input_dim, fan_out, num_nets)
W = np.random.randn(input_dim, fan_out, num_nets)

# A: shape (fan_out, output_dim, num_nets)
A = np.random.randn(fan_out, output_dim, num_nets)

# losses: one per network
losses = np.array([0.5, 0.3, 0.8, 0.2, 0.9])

# original_signs: one per neuron across all networks
total_neurons = fan_out * num_nets
original_signs = np.array([1, -1, 1, -1, 1, 1])

# clusters: list of arrays, each containing neuron indices
clusters = [
    np.array([0, 1, 2]),
    np.array([3, 4, 5])
]

# cluster_indices: list of arrays with same structure as clusters
cluster_indices = [
    np.array([0, 1, 2]),
    np.array([3, 4, 5])
]

# Parameters
final_layer = False
symmetry = 'odd'
verbose = True

ARGS = {
    'clusters': clusters,
    'cluster_indices': cluster_indices,
    'W': W,
    'A': A,
    'N': N,
    'losses': losses,
    'fan_out': fan_out,
    'final_layer': final_layer,
    'original_signs': original_signs,
    'symmetry': symmetry,
    'verbose': verbose
}
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
find_clusters Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("a31faab28f197479")
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
from scipy.cluster import hierarchy
from scipy.spatial.distance import pdist, squareform

# Create a small matrix of vectors for clustering
np.random.seed(0)
w = np.random.randn(10, 4)  # 10 samples, 4 dimensions

# Create a cluster mask (optional parameter)
cluster_mask = np.ones(4)  # Simple mask that doesn't filter anything

ARGS = {
    'w': w,
    'min_size': 2,
    'plateau_threshold': 0.1,
    'fix_clusters': None,
    'linkage': 'average',
    'max_clusters': False,
    'dist': 'L2',
    'forced_cut_height': None,
    'cluster_mask': cluster_mask,
    'verbose': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
plot_dendrogram Ran
ran; our contract draft was wrong, not the code
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("c23192bf76f61153")
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 sys
import matplotlib.pyplot as plt
from scipy.cluster import hierarchy
import numpy as np

# Create a linkage matrix H for hierarchical clustering
# The linkage matrix should be a (n-1, 4) array where n is the number of samples
# Each row represents a merge in the dendrogram
# Columns: [cluster1_idx, cluster2_idx, distance, sample_count]

n_samples = 5
H = np.array([
    [0, 1, 0.5, 2],
    [2, 3, 1.2, 2],
    [4, 5, 1.8, 3],
    [6, 7, 2.5, 5]
], dtype=np.float64)

ARGS = {
    "H": H,
    "color_threshold": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, scipy — 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
plot_simmat Ran
ran; our contract draft was wrong, not the code
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("359ab3046482ad86")
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 numpy as np
from scipy.cluster import hierarchy
from scipy.spatial.distance import pdist, squareform

# Create a small similarity/distance matrix
# We need to create a condensed distance matrix (upper triangle)
# For a 5x5 matrix, we need 5*4/2 = 10 values
np.random.seed(0)
n_samples = 5
# Create random points and compute pairwise distances
points = np.random.rand(n_samples, 3)
simmat = pdist(points, metric='euclidean')

# Compute hierarchical clustering linkage matrix
expanded_simmat = squareform(simmat)
H = hierarchy.linkage(simmat, method='average')

ARGS = {
    'H': H,
    'simmat': simmat
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib, numpy, scipy — 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
remove_unaligned_clusters Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("836b9a54a8c748fb")
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 sample clusters - list of numpy arrays
# Each cluster should have multiple vectors (>1 element as per docstring)
cluster1 = np.array([
    [1.0, 0.0, 0.0, 0.0],
    [0.9, 0.1, 0.0, 0.0],
])

cluster2 = np.array([
    [0.0, 1.0, 0.0, 0.0],
    [0.0, 0.9, 0.1, 0.0],
])

cluster3 = np.array([
    [1.0, 0.5, 0.2, 0.1],
    [-1.0, -0.5, -0.2, -0.1],
])

C = [cluster1, cluster2, cluster3]

# Indices for these clusters
C_idx = [0, 1, 2]

# Beta: alignment threshold angle in radians (e.g., 30 degrees)
beta = np.pi / 6  # 30 degrees

# Cluster mask: optional mask to apply to vectors before clustering
cluster_mask = np.array([1.0, 1.0, 0.5, 0.5])

# Verbose flag
verbose = True

ARGS = {
    "C": C,
    "C_idx": C_idx,
    "beta": beta,
    "cluster_mask": cluster_mask,
    "verbose": verbose,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
plot_alignments Not yet run
unverified (harvested, no recorded run)
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("875e0fc12b8a08d0")
How it ran

no invocation recorded.

reconstruct_layer Not yet run
unverified (harvested, no recorded run)
flavio-martinelli/expand-and-cluster/extraction/layer_reconstruction.py
code served (permissive licence) · get_code("e5e452af984ab0cf")
How it ran

no invocation recorded.

Also present in other papers' code

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

Can we identify the weights of a neural network by probing its input-output mapping? At first glance, this problem seems to have many solutions because of permutation, overparameterisation and activation function symmetries. Yet, we show that the incoming weight vector of each neuron is identifiable up to sign or scaling, depending on the activation function. Our novel method 'Expand-and-Cluster' can identify layer sizes and weights of a target network for all commonly used activation functions. Expandand-Cluster consists of two phases: (i) to relax the non-convex optimisation problem, we train multiple overparameterised student networks to best imitate the target function; (ii) to reverse engineer the target network's weights, we employ an ad-hoc clustering procedure that reveals the learnt weight vectors shared between studentsthese correspond to the target weight vectors. We demonstrate successful weights and size recovery of trained shallow and deep networks with less than 10% overhead in the layer size and describe an 'ease-of-identifiability' axis by analysing 150 synthetic problems of variable difficulty.

For agents

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

get_harvested_code_for_paper("2304.12794")
get_code_for_paper("2304.12794")
have("2304.12794")

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

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

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

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

Connect an agent — have() is free.