SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1610.04794 · 2016

Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 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, 1 violated it and 0 have no contract verdict; 1 failure of our instrument; 0 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/1610.04794.json · badge: /api/ran/1610.04794.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
astorfi/deep-clustering-kmeans reimplementation (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
XiaoxiangLin/DCN-keras reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
acc Ran
ran, violated the contract we drafted
XiaoxiangLin/DCN-keras/metrics.py
pointer only (licence: NONE) · get_code("9a1b2634815f4f53")
How it ran

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

evaluate Ran
ran, honoured the contract we drafted
astorfi/deep-clustering-kmeans/mnist.py
code served (permissive licence) · get_code("756bcc3c5f2e18a4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class SimpleAutoencoder(nn.Module):
    def __init__(self, input_dim=12, latent_dim=5):
        super().__init__()
        self.encoder = nn.Linear(input_dim, latent_dim)
        self.decoder = nn.Linear(latent_dim, input_dim)
        
    def forward(self, x, latent=False):
        encoded = self.encoder(x)
        if latent:
            return encoded
        decoded = self.decoder(encoded)
        return decoded

class SimpleKMeans:
    def __init__(self, n_clusters=3):
        self.n_clusters = n_clusters
        self.centers = np.random.randn(n_clusters, 5)
        
    def update_assign(self, X):
        # Assign each point to nearest cluster
        distances = np.zeros((X.shape[0], self.n_clusters))
        for i in range(self.n_clusters):
            distances[:, i] = np.sum((X - self.centers[i])**2, axis=1)
        return np.argmin(distances, axis=1)

class Model:
    def __init__(self):
        self.device = torch.device('cpu')
        self.autoencoder = SimpleAutoencoder(input_dim=12, latent_dim=5)
        self.kmeans = SimpleKMeans(n_clusters=3)

model = Model()

# Create test_loader as a list of (data, target) tuples
# data: batch_size x features (will be reshaped to batch_size x -1)
# target: batch_size labels
test_loader = [
    (torch.randn(2, 3, 4), torch.tensor([0, 1])),  # 2 samples, 3x4 = 12 features
    (torch.randn(2, 3, 4), torch.tensor([2, 0])),  # 2 samples
]

ARGS = {
    'model': model,
    'test_loader': test_loader
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, sklearn, torch — 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
solver Ran
ran; our contract draft was wrong, not the code
astorfi/deep-clustering-kmeans/mnist.py
code served (permissive licence) · get_code("979bf0d41d1a040c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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
import numpy as np

torch.manual_seed(0)

class SimpleAutoencoder(nn.Module):
    def __init__(self, input_dim, latent_dim):
        super().__init__()
        self.encoder = nn.Linear(input_dim, latent_dim)
        self.decoder = nn.Linear(latent_dim, input_dim)
    
    def forward(self, x, latent=False):
        z = self.encoder(x)
        if latent:
            return z
        return self.decoder(z)

class SimpleKMeans:
    def __init__(self, n_clusters, latent_dim):
        self.n_clusters = n_clusters
        self.centers = np.random.randn(n_clusters, latent_dim)
    
    def update_assign(self, X):
        # Assign each point to nearest cluster
        distances = np.sum((X[:, np.newaxis, :] - self.centers[np.newaxis, :, :]) ** 2, axis=2)
        return np.argmin(distances, axis=1)

class StandInModel(nn.Module):
    def __init__(self, input_dim=12, latent_dim=5, n_clusters=3):
        super().__init__()
        self.device = torch.device('cpu')
        self.autoencoder = SimpleAutoencoder(input_dim, latent_dim)
        self.kmeans = SimpleKMeans(n_clusters, latent_dim)
        self.input_dim = input_dim
        self.latent_dim = latent_dim
    
    def pretrain(self, train_loader, pre_epoch):
        rec_loss_list = []
        criterion = nn.MSELoss()
        optimizer = torch.optim.Adam(self.autoencoder.parameters(), lr=0.001)
        
        for epoch in range(pre_epoch):
            total_loss = 0.0
            for data, target in train_loader:
                batch_size = data.size()[0]
                data = data.view(batch_size, -1).to(self.device)
                optimizer.zero_grad()
                recon = self.autoencoder(data, latent=False)
                loss = criterion(recon, data)
                loss.backward()
                optimizer.step()
                total_loss += loss.item()
            rec_loss_list.append(total_loss / len(train_loader))
        return rec_loss_list
    
    def fit(self, epoch, train_loader):
        # Simplified fit method
        for data, target in train_loader:
            batch_size = data.size()[0]
            data = data.view(batch_size, -1).to(self.device)
            latent_X = self.autoencoder(data, latent=True)
            latent_X = latent_X.detach().cpu().numpy()
            # Update kmeans centers (simplified)
            assignments = self.kmeans.update_assign(latent_X)

class Args:
    def __init__(self):
        self.pre_epoch = 2
        self.epoch = 3

# Create tiny dataset
# Input images are 3x4 = 12 dimensional when flattened
train_data = [
    (torch.randn(2, 3, 4), torch.tensor([0, 1])),
    (torch.randn(2, 3, 4), torch.tensor([2, 0])),
]

test_data = [
    (torch.randn(2, 3, 4), torch.tensor([1, 2])),
    (torch.randn(2, 3, 4), torch.tensor([0, 1])),
]

model = StandInModel(input_dim=12, latent_dim=5, n_clusters=3)
args = Args()

ARGS = {
    'args': args,
    'model': model,
    'train_loader': train_data,
    'test_loader': test_data
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, sklearn, 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

Also present in other papers' code

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

Most learning approaches treat dimensionality reduction (DR) and clustering separately (i.e., sequentially), but recent research has shown that optimizing the two tasks jointly can substantially improve the performance of both. The premise behind the latter genre is that the data samples are obtained via linear transformation of latent representations that are easy to cluster; but in practice, the transformation from the latent space to the data can be more complicated. In this work, we assume that this transformation is an unknown and possibly nonlinear function. To recover the `clustering-friendly' latent representations and to better cluster the data, we propose a joint DR and K-means clustering approach in which DR is accomplished via learning a deep neural network (DNN). The motivation is to keep the advantages of jointly optimizing the two tasks, while exploiting the deep neural network's ability to approximate any nonlinear function. This way, the proposed approach can work well for a broad class of generative models. Towards this end, we carefully design the DNN structure and the associated joint optimization criterion, and propose an effective and scalable algorithm to handle the formulated optimization problem. Experiments using different real datasets are employed to showcase the effectiveness of the proposed approach.

For agents

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

get_harvested_code_for_paper("1610.04794")
get_code_for_paper("1610.04794")
have("1610.04794")

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

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

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

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

Connect an agent — have() is free.