---
title: E-Means Efficient Clustering Algorithm
url: https://www.emergentmind.com/topics/e-means
type: topic
---

# E-Means Efficient Clustering Algorithm

e-means is a mini-batch optimization procedure for $k$-means clustering that uses exponential moving averages (EMAs) of cluster counts and vector sums rather than conventional full-batch centroid recomputation or stochastic-gradient updates. Introduced for large, high-dimensional embedding datasets, it combines EMA centroid updates with cosine-annealed step sizes, dead-cluster revival, optional finalization procedures, and empirically fitted scaling laws for batch size and learning rate. The method is designed to reduce the number of data passes required to reach a specified clustering loss while retaining the squared-Euclidean $k$-means objective [2611.09501].

## 1. Terminology and scope

The designation “e-means” is not historically univocal. In the contemporary clustering literature, it denotes the EMA-based method introduced in “e-means: outperforming k-means (in one-tenth the epochs)” [2611.09501]. Earlier or unrelated works use similar terminology in different senses.

The 2012 paper “Reclassification formula that provides to surpass K-means method” does not formally call its method e-means. It introduces the Kh-method, an alternative to conventional $k$-means based on an exact reclassification formula and iterative correction [1209.6204]. The Kh-method retains the within-cluster squared-error objective but allows group reassignments and seeks partitions stable under permitted reclassifications.

In mathematical analysis of means, “e-mean” may be used descriptively for an expectation-of-means inequality,
$$
\mathbb E[m(X,Y)]\leq m(\mathbb E X,\mathbb E Y),
$$
whose validity for all positive random variables characterizes concavity of the representing function of a numerical mean [1608.08671]. Other papers use related terminology for extended means and invariant means, electronic teaching and learning resources, exponential multi-view fuzzy clustering, or ME-estimators based on e-statistics [1807.09045; 2207.05439; 2503.22932; 2605.30485].

In clustering, therefore, e-means should be distinguished from:

- **The Kh-method**: an exact group-reclassification procedure for reducing $k$-means error [1209.6204].
- **E-MVFCM and EB-MVFCM**: exponential multi-view fuzzy $c$-means models whose exponential component modifies the distance transformation rather than defining an EMA optimizer [2503.22932].
- **E$^2$CM**: Early Exit Class Means, a neural-network inference mechanism based on intermediate-layer class centroids [2103.01148].
- **ME-estimation**: point estimation by minimizing an e-statistic [2605.30485].

The remainder of this article uses e-means in its principal contemporary sense: the EMA-based mini-batch $k$-means algorithm.

## 2. Objective and relation to $k$-means

Given a dataset
$$
X=\{x_1,x_2,\ldots,x_n\}\subset\mathbb R^d
$$
and $k$ centroids $\mathcal C=(c_1,\ldots,c_k)$, e-means optimizes the standard nearest-centroid mean-squared error,
$$
\operatorname{MSE}(X,\mathcal C)
=
\frac{1}{n}
\sum_{i=1}^{n}
\left\|x_i-c_{a(i)}\right\|^2,
$$
where
$$
a(i)=\arg\min_{j\in\{1,\ldots,k\}}\|x_i-c_j\|^2.
$$

The objective is the same as in ordinary $k$-means. The difference lies in the optimization procedure.

Lloyd’s algorithm alternates between assigning every observation to its nearest centroid and replacing each centroid with the arithmetic mean of all points assigned to it. Each iteration requires a complete pass through the dataset. Classical mini-batch $k$-means instead updates centroids using batches and step-size rules, including MacQueen’s sequential rule and Sculley’s scalable mini-batch method.

The e-means paper identifies several limitations of conventional mini-batch approaches:

- their final approximation error is often higher than Lloyd’s;
- step-size and batch-size parameters commonly require tuning;
- large-batch gradient updates can become unstable;
- clusters may become dead and receive no further assignments.

E-means retains mini-batch processing but maintains smoothed sufficient statistics for each cluster. Its centroid is always computed as a ratio of an exponentially averaged vector sum and an exponentially averaged count. This mean-preserving structure distinguishes it from unconstrained gradient displacement.

## 3. EMA centroid updates

For a mini-batch $\mathcal B$, let
$$
n_j=
\left|
\{x\in\mathcal B:a(x)=j\}
\right|
$$
be the number of assigned points in cluster $j$, and let
$$
s_j=
\sum_{\substack{x\in\mathcal B\\a(x)=j}}x
$$
be their vector sum.

E-means maintains two state variables for every cluster:

- $N_j\in\mathbb R_+$: an exponentially averaged cluster count;
- $S_j\in\mathbb R^d$: an exponentially averaged cluster sum.

For EMA decay $\gamma\in[0,1)$, the update is
$$
N_j\leftarrow \gamma N_j+(1-\gamma)n_j,
$$
$$
S_j\leftarrow \gamma S_j+(1-\gamma)s_j.
$$

The centroid is then
$$
c_j=\frac{S_j}{N_j}.
$$

Writing $\alpha=1-\gamma$, the update can be interpreted as moving the centroid toward the current batch’s assigned-point mean through smoothed count and sum statistics. Because the centroid is represented as a weighted mean of accumulated assigned data, the method preserves a mean-like geometric structure. The paper contrasts this with SGD updates, which can move a centroid outside the convex hull represented by assigned points.

### Initialization

The initial centroids $c_j^{(0)}$ are obtained by uniformly sampling $k$ points from the dataset. The associated statistics are initialized as
$$
N_j=10^{-10},
\qquad
S_j=N_jc_j^{(0)}.
$$

Consequently,
$$
\frac{S_j}{N_j}=c_j^{(0)}
$$
at initialization, while the small initial count makes the initialization’s statistical contribution negligible after real batches have been processed.

E-means does not use a separate Adam-style EMA bias correction such as division by $1-\gamma^t$. The consistent initialization of $S_j$ and $N_j$ makes the centroid ratio well-defined from the first update.

### Update geometry

The EMA construction is intended to remain stable at large batch sizes. In the paper’s interpretation, gradient-based updates apply a displacement that need not preserve the convex-hull property of assigned observations, whereas the EMA centroid remains a smoothed mean. This geometric explanation is supported by the form of the update and by empirical comparisons, but the complete algorithm—with annealing, revival, and approximate assignment—does not have a general global-convergence proof.

## 4. Annealing, revival, and finalization

### Cosine-annealed step size

E-means does not use a fixed EMA decay as its principal recipe. If $T$ is the number of epochs and $B$ the batch size, the total number of mini-batch updates is
$$
M=T\left\lfloor\frac{n}{B}\right\rfloor.
$$

The step size is
$$
\alpha(t)
=
\alpha_0
\left(
\varepsilon+
(1-\varepsilon)
\frac12
\left(
1+\cos\left(\frac{\pi t}{M}\right)
\right)
\right),
\qquad
\varepsilon=0.1,
$$
with
$$
\gamma(t)=1-\alpha(t).
$$

The high initial step permits rapid adaptation from a random initialization. The decreasing step stabilizes centroids as assignments become more reliable. Ablation results in the paper report that cosine annealing usually improves training MSE and often improves test MSE relative to a tuned fixed step, although its test-MSE effect can be neutral or slightly negative in some settings.

### Dead-cluster revival

A cluster is checked for underuse every five batches. It is considered underused when
$$
N_j<
\tau\frac1k\sum_{i=1}^{k}N_i,
\qquad
\tau=0.1.
$$

The underused cluster is revived by splitting a donor cluster. A donor $j'$ is sampled with probability proportional to $N_{j'}$. The donor and the revived cluster receive slightly perturbed versions of the donor centroid:
$$
c_j:=c_{j'}\odot[1+\delta,1-\delta,1+\delta,\ldots],
$$
$$
c_{j'}:=c_{j'}\odot[1-\delta,1+\delta,1-\delta,\ldots],
$$
where $\odot$ denotes elementwise multiplication and $\delta\ll1$. The perturbation is at the machine-epsilon scale of BF16 in the reported implementation.

The statistics are reset consistently:
$$
S_j=c_jN_j,
\qquad
S_{j'}=c_{j'}N_{j'},
$$
with the donor count split approximately in half.

In an ablation on DEEP with $n=10^6$ and $k=16{,}384$, disabling revival increased training MSE by about $2.97\%$ and test MSE by $2.24\%$. The reported dead-cluster proportions were approximately $0.3\%$ with revival, $14.3\%$ with resampling, and $26.3\%$ without revival.

### Finalization

The EMA state used during optimization is not necessarily the best final representation for every evaluation criterion.

For training-loss minimization, e-means can record assignments from the final epoch and replace every centroid with the exact mean of its assigned points:
$$
c_j=
\frac{1}{|A_j|}
\sum_{i\in A_j}x_i,
$$
where $A_j$ is the set of points assigned to cluster $j$. This does not increase the loss for those fixed assignments.

For out-of-sample performance, the method can use a second, slower EMA of counts and sums. Its half-life controls the degree of smoothing. The slower EMA can improve test MSE, particularly when $n/k$ is small, by trading some training-set fit for reduced overfitting.

## 5. Formulaic scaling laws

A central aim of e-means is to reduce dependence on hyperparameter sweeps. The authors fit empirical power laws in log space using optimization runs on the DEEP dataset and assess transfer to other datasets.

The peak step size is modeled as
$$
\alpha_0
=
\min\left(
a_c k^{a_k}B^{a_B}n^{a_n}T^{a_T},
1
\right),
$$
with reported coefficients
$$
a_c=0.824,\qquad
a_k=-0.46,\qquad
a_B=0.90,\qquad
a_n=-0.45,\qquad
a_T=-0.11.
$$

Thus the reported rule is
$$
\alpha_0=
\min\left(
0.824\,k^{-0.46}B^{0.90}n^{-0.45}T^{-0.11},
1
\right).
$$

According to the fitted relation, larger batch sizes require larger effective steps, whereas increasing $k$ or $n$ reduces the peak step. A larger epoch budget also leads to a modestly smaller peak step.

The batch-size law is
$$
B=c_B k^{b_k}n^{b_n}T^{b_T},
$$
with
$$
c_B=0.035,\qquad
b_k=0.13,\qquad
b_n=0.88,\qquad
b_T=0.81.
$$

The batch size is rounded to the nearest power of two and capped at $n$. For datasets with $n>2$ million, the paper reports using the batch-law prediction divided by $8$.

The batch law is based on a quality “knee”: the largest batch size whose validation MSE lies within $0.2\%$ of the best value on the batch-size curve. The reported held-out median excess MSE was $0.19\%$. The fitted log-space models achieved approximately $R^2=0.95$ for the step law and $R^2=0.96$ for the batch law; the reported median held-out regret for the decay law was approximately $0.07\%$.

These laws are empirical regressions rather than convergence theorems. Their validity was assessed on high-dimensional embedding workloads, and the paper identifies low-dimensional, very small, and low-intrinsic-dimensionality datasets as settings where they may be less reliable. The fitted laws do not include an explicit embedding-dimension term because attempts to fit one produced an unstable exponent.

## 6. Evaluation, performance, and limitations

### Experimental domains

The principal evaluation covers image descriptors, image embeddings, text embeddings, and very large embedding collections. Datasets include SIFT, DEEP, SPACEV, SimSearchNet++, AG-News, ImageNet-CLIP, arXiv, and DINO10B. Their dimensions range from $96$ to $1024$, and dataset sizes range from approximately $0.75$ million to $10$ billion vectors.

The principal metric is held-out MSE,
$$
\operatorname{MSE}(X,\mathcal C)
=
\frac1n
\sum_i
\|x_i-c_{a(i)}\|^2.
$$

The experiments compare e-means with Lloyd $k$-means, greedy $k$-means++, Faiss, Flash-KMeans, cuML, Sculley mini-batch $k$-means, Staleness-Reduction, SuperKMeans, SGD, Adam, and SparseAdam. GPU experiments use H100 80-GB GPUs, while CPU experiments use a 64-core Xeon Platinum 8462Y+.

### Reported convergence and speed

Across the main GPU comparisons, e-means reached the test MSE of Flash-KMeans at 25 iterations in approximately $1.4$–$2.6$ epochs. Reported GPU speedups range from approximately $9.5\times$ to $45.5\times$, commonly summarized as $10$–$45\times$.

For $1$ million points and $16{,}384$ clusters, the reported e-means epoch range was $1.4$–$2.4$, with speedups of $9.5$–$12.9\times$. For $1$ billion points and $1{,}048{,}576$ clusters, it required $1.4$–$2.0$ epochs and achieved speedups of $21.2$–$45.5\times$.

On eleven VIBE datasets, e-means required between $1.6$ and $2.6$ epochs to reach the Lloyd-at-25 reference, with GPU speedups of $8.0$–$22.8\times$ over Flash-KMeans and CPU speedups of $9.0$–$15.0\times$ over Faiss.

At five epochs, e-means achieved lower test MSE than Flash-KMeans at 25 iterations on all eight tabulated configurations. Against Flash-KMeans with greedy $k$-means++ initialization, e-means still had lower mean error after five epochs in all eight configurations, although the advantage narrowed to approximately $0.06\%$–$0.33\%$.

For the full 10-billion-vector DINO10B dataset with approximately 16.7 million clusters, the reported exact-assignment comparison was:

- Lloyd at 25 epochs: $6{,}784$ GPU-hours on 64 machines;
- e-means at $2.5$ epochs: $779$ GPU-hours on 32 machines.

E-means exceeded Lloyd’s test loss in $2.5$ epochs. With approximate IVF assignment, it reached Lloyd’s test loss in approximately three to four epochs on one machine; one reported configuration required approximately $22.8$ GPU-hours.

These results are empirical and workload-dependent. They do not establish that e-means globally dominates Lloyd’s algorithm or $k$-means++ on every dataset.

### Failure modes and implementation constraints

The method remains subject to the computational cost of nearest-centroid assignment. Exact assignment requires approximately
$$
O(Bkd)
$$
work per batch and approximately
$$
O(Tnkd)
$$
work over $T$ epochs. EMA updates require approximately $O(kd)$ work per batch when all centroid statistics are materialized. Memory is approximately $O(kd)$ for sums, $O(k)$ for counts, and $O(Bd)$ for batch storage.

Approximate IVF assignment can reduce assignment cost but introduces assignment noise. The paper reports that IVF may alter training MSE, while test MSE can sometimes improve through a regularization effect. Stale IVF indices can produce sawtooth loss curves and degrade final quality.

Other limitations include:

- **Cluster imbalance**: very small clusters provide unreliable EMA statistics.
- **Low $n/k$**: finalization becomes more important when few observations support each cluster.
- **Overfitting**: training MSE may continue to decrease while test MSE increases.
- **Scaling-law transfer**: the fitted exponents may be suboptimal outside the high-dimensional embedding regime.
- **Numerical precision**: BF16, FP8, and INT8 assignment were evaluated, with FP32 EMA statistics; reported test-MSE differences were approximately within $0.13\%$ of BF16 in the tested configurations.
- **No general convergence theorem**: the full procedure combines nonconvex assignments, annealed EMA updates, revival, and optional approximate assignment.

E-means is therefore best characterized as an engineering and optimization method for fixed-data mini-batch $k$-means at large scale. Its defining mechanism is the ratio of EMA cluster sums to EMA cluster counts; its practical system consists of annealing, dead-cluster revival, finalization, and formulaic parameter selection. The reported reductions in epochs, losses, and GPU time are substantial on the evaluated embedding workloads, while their generality depends on data distribution, cluster scale, dimensionality, assignment accuracy, and hardware implementation [2611.09501].

Source: https://www.emergentmind.com/topics/e-means