SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.03209 · ICML · 2023

End-to-end Differentiable Clustering with Associative Memories

Dmitry Krotov, Mohammed Zaki, Parikshit Ram, Bishwajit Saha

arXiv · PDF · Open in the Atlas

Code that ran

9 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 9 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2306.03209.json · badge: /api/ran/2306.03209.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
bsaha205/clam canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
calculate_dist_to_closest_memory Ran
ran on a synthesized input
bsaha205/clam/result_helper.py
code served (permissive licence) · get_code("38ba031ceaf3f105")
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 numpy as np

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

# Create sample cluster centers - 3 clusters in 4-dimensional space
cluster_center = [
    np.array([0.0, 0.0, 0.0, 0.0]),
    np.array([1.0, 1.0, 1.0, 1.0]),
    np.array([2.0, 2.0, 2.0, 2.0])
]

# Create sample data points - 2 points in 4-dimensional space
X = [
    np.array([0.1, 0.1, 0.1, 0.1]),
    np.array([1.5, 1.5, 1.5, 1.5])
]

ARGS = {
    'cluster_center': cluster_center,
    'X': X
}
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 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
class2int Ran
ran on a synthesized input
bsaha205/clam/parser.py
code served (permissive licence) · get_code("211e16993c7356dc")
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
import numpy as np

torch.manual_seed(0)

# Reset globals before defining ARGS
clmap = {}
clcnt = 0

def class2int(c):
    global clcnt
    c = c.strip('"')
    if c not in clmap:
        clmap[c] = clcnt
        clcnt += 1
    return clmap[c]

# The function takes one parameter 'c' which is a string
# It strips quotes from it and uses it as a dictionary key
# So we need to pass a string that may have quotes

ARGS = {
    'c': '"ClassA"'
}
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 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
construct_masked_data Ran
ran on a synthesized input
bsaha205/clam/helper.py
code served (permissive licence) · get_code("592035015952d508")
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 3, 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
import tensorflow as tf

np.random.seed(0)

# Create small test data
batch_size = 2
dimension = 4

# original_data needs to be a tf.Tensor that has .numpy() method
original_data = tf.constant([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=tf.float32)

# mask_prob - probability of masking each dimension
mask_prob = 0.5

# mask_value - replacement values for masked indices, should match dimension size
mask_value = np.array([0.0, 0.0, 0.0, 0.0])

# is_entire_dim - whether to use same mask for all sequences
is_entire_dim = False

ARGS = {
    "original_data": original_data,
    "dimension": dimension,
    "mask_prob": mask_prob,
    "mask_value": mask_value,
    "is_entire_dim": is_entire_dim
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, 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
find_closest_center Ran
ran on a synthesized input
bsaha205/clam/result_helper.py
code served (permissive licence) · get_code("e19839fc8f780c2e")
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
import numpy as np
from scipy.spatial import distance

torch.manual_seed(0)

# cluster_centers should be a list or array of points
# point should be a single point (1D array or list)
# The function iterates through cluster_centers with len() and indexes with [j]
# It calls distance.euclidean() on each center and the point

cluster_centers = [
    np.array([0.0, 1.0, 2.0, 3.0]),
    np.array([1.0, 2.0, 3.0, 4.0]),
    np.array([2.0, 3.0, 4.0, 5.0]),
]

point = np.array([0.5, 1.5, 2.5, 3.5])

ARGS = {
    "cluster_centers": cluster_centers,
    "point": point,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, 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
generate_data Ran
ran on a synthesized input
bsaha205/clam/plot_gaussian.py
code served (permissive licence) · get_code("ac7a55ce33b3c50e")
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 (12, 2) 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

ARGS = {
    "xpoints": 3,
    "ypoints": 4,
}
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 (12, 2) — shape (12, 2) 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_labels Ran
ran on a synthesized input
bsaha205/clam/plot_2d_cluster.py
code served (permissive licence) · get_code("9a42a204358a928e")
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 int; 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.spatial import distance

def generate_data(xpoints, ypoints):
    M = []
    xstep = 1 / xpoints
    ystep = 1 / ypoints
    x = 0
    for i in range(xpoints):
        grid_x = []
        grid_y = []
        y = 0
        for j in range(ypoints):
            grid_x.append(x)
            grid_y.append(y)
            y += ystep
        M.append(np.stack((grid_x, grid_y), axis=1))
        x += xstep
    M = np.array(M)
    M = np.reshape(M, (xpoints * ypoints, 2))
    return M

def get_labels(M, memories):
    labels = []
    for i in range(M.shape[0]):
        min_dist = 100000
        for j in range(len(memories)):
            euclid_dist = distance.euclidean(M[i], memories[j])
            if euclid_dist < min_dist:
                min_dist = euclid_dist
                label = j
        labels.append(label)
    return labels

# Create small test data
M = np.array([
    [0.1, 0.2],
    [0.3, 0.4],
    [0.5, 0.6],
    [0.7, 0.8]
], dtype=np.float32)

memories = [
    np.array([0.0, 0.0], dtype=np.float32),
    np.array([1.0, 1.0], dtype=np.float32),
    np.array([0.5, 0.5], dtype=np.float32)
]

ARGS = {
    "M": M,
    "memories": memories
}
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 list, ndim 1, dtype family int — 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
mean_squared_error Ran
ran on a synthesized input
bsaha205/clam/plot_gaussian.py
code served (permissive licence) · get_code("b0bcf4780fb72330")
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 EagerTensor, 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 tensorflow as tf
import numpy as np

# Create small tensors for y_true and y_pred
batch_size = 2
dim = 4

y_true = tf.constant(np.random.randn(batch_size, dim).astype(np.float32))
y_pred = tf.constant(np.random.randn(batch_size, dim).astype(np.float32))
mask = tf.constant(np.ones((batch_size, dim), dtype=np.float32))

ARGS = {
    "y_true": y_true,
    "y_pred": y_pred,
    "mask": mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
mean_squared_loss Ran
ran on a synthesized input
bsaha205/clam/helper.py
code served (permissive licence) · get_code("4a8531d986fd4fc4")
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 EagerTensor, 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 tensorflow as tf
import numpy as np

# Create small tensors for the function
batch_size = 2
dim = 4

# y_true: ground truth values
y_true = tf.constant(np.random.randn(batch_size, dim).astype(np.float32))

# y_pred: predicted values
y_pred = tf.constant(np.random.randn(batch_size, dim).astype(np.float32))

# mask: binary mask to weight the loss
mask = tf.constant(np.array([[1.0, 1.0, 0.0, 1.0],
                               [1.0, 0.0, 1.0, 1.0]], dtype=np.float32))

ARGS = {
    'y_true': y_true,
    'y_pred': y_pred,
    'mask': mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
read_file Ran
ran on a synthesized input
bsaha205/clam/parser.py
code served (permissive licence) · get_code("06620495a0b9b97e")
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 (2, 4) 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 os
import numpy as np
import scipy.io
import tempfile
import shutil

# Create a temporary directory for test data
test_dir = tempfile.mkdtemp()
data_dir = os.path.join(test_dir, 'data')
os.makedirs(data_dir, exist_ok=True)

# Create test files
# Test case 1: simple text file with space/tab delimiter
simple_file = os.path.join(data_dir, 'simple.txt')
with open(simple_file, 'w') as f:
    f.write("1.0 2.0 3.0 class_a\n")
    f.write("4.0 5.0 6.0 class_b\n")

# Test case 2: USPS format file
usps_file = os.path.join(data_dir, 'usps.t')
with open(usps_file, 'w') as f:
    f.write("1 1:0.5 2:0.3 3:0.1\n")
    f.write("2 1:0.4 2:0.2 3:0.0\n")

# Test case 3: MAT file
mat_file = os.path.join(data_dir, 'test.mat')
scipy.io.savemat(mat_file, {
    'X': np.array([[1.0, 2.0], [3.0, 4.0]]),
    'Y': np.array([[0], [1]])
})

# Test case 4: CIFAR-like files
cifar_data_file = os.path.join(data_dir, 'cifar_data.txt')
cifar_label_file = os.path.join(data_dir, 'cifar_labels.txt')
with open(cifar_data_file, 'w') as f:
    f.write("1.0,2.0,3.0\n")
    f.write("4.0,5.0,6.0\n")
with open(cifar_label_file, 'w') as f:
    f.write("cat\n")
    f.write("dog\n")

# Change to test directory
original_cwd = os.getcwd()
os.chdir(test_dir)

ARGS = {
    'fname': 'simple.txt',
    'delimiter': ' ',
    'label_filename': None
}
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 ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
DCEC_clustering Not yet run
unverified (harvested, no recorded run)
bsaha205/clam/s_kmeans.py
code served (permissive licence) · get_code("0343061c14e6fdd9")
How it ran

no invocation recorded.

energy_loss Not yet run
unverified (harvested, no recorded run)
bsaha205/clam/helper.py
code served (permissive licence) · get_code("fd9d927238dd5f18")
How it ran

no invocation recorded.

get_init_mem Not yet run
unverified (harvested, no recorded run)
bsaha205/clam/result_helper.py
code served (permissive licence) · get_code("39aa1230c0f6c727")
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-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

Clustering is a widely used unsupervised learning technique involving an intensive discrete optimization problem. Associative Memory models or AMs are differentiable neural networks defining a recursive dynamical system, which have been integrated with various deep learning architectures. We uncover a novel connection between the AM dynamics and the inherent discrete assignment necessary in clustering to propose a novel unconstrained continuous relaxation of the discrete clustering problem, enabling end-to-end differentiable clustering with AM, dubbed ClAM. Leveraging the pattern completion ability of AMs, we further develop a novel self-supervised clustering loss. Our evaluations on varied datasets demonstrate that ClAM benefits from the selfsupervision, and significantly improves upon both the traditional Lloyd's k-means algorithm, and more recent continuous clustering relaxations (by upto 60% in terms of the Silhouette Coefficient).

For agents

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

get_harvested_code_for_paper("2306.03209")
get_code_for_paper("2306.03209")
have("2306.03209")

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

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

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

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

Connect an agent — have() is free.