Year: 2019

Abstract:
We propose a deep amortized clustering (DAC), a neural architecture which learns to cluster datasets efficiently using a few forward passes. DAC implicitly learns what makes a cluster, how to group data points into clusters, and how to count the number of clusters in datasets. DAC is meta-learned using labelled datasets for training, a process distinct from traditional clustering algorithms which usually require hand-specified prior knowledge about cluster shapes/structures. We empirically show, on both synthetic and image data, that DAC can efficiently and accurately cluster new datasets coming from the same distribution used to generate training datasets.

text: 1 INTRODUCTION
Clustering is a fundamental task in unsupervised machine learning to group similar data points into multiple clusters. Aside from its usefulness in many downstream tasks, clustering is an important tool for visualising and understanding the underlying structures of datasets, as well as a model for categorisation in cognitive science.
Most clustering algorithms have two basic components - how to define a cluster and how to assign data points to those clusters. The former is usually defined using metrics to measure distances between data points, or using generative models describing the shapes of clusters. The latter, how to assign data points to the clusters, is then typically optimized iteratively w.r.t. objective functions derived based on the cluster definitions. Note that cluster definitions are user defined, and are reflections of the user’s prior knowledge about the clustering process, with different definitions leading to different clusterings. However, cluster definitions used in practice are often quite simple, for example clusters in k-means are defined in terms of `2 distance to centroids, while Gaussians are a commonly used generative model for clusters in mixture models.
Recently, advances in deep learning has facilitated the approximation of complex functions in a black-box fashion. One particular application of relevance to the problem of clustering in this paper is
that of amortized inference (Gershman & Goodman, 2014; Stuhlmüller et al., 2013), where neural networks are trained to predict the states of latent variables given observations in a generative model or probabilistic programme. In the context of learning set-input neural networks (Zaheer et al., 2017), Lee et al. (2019) showed that it is possible to amortize the iterative clustering process for a Mixture of Gaussians (MOG), while Pakman et al. (2019) demonstrated that it is possible to train a neural network to sequentially assign data points to clusters. Both approaches can be interpreted as using neural networks for amortized inference of cluster assignments and parameters given a dataset. Note that once neural networks are used for amortized clustering, we can take advantage of their flexibility in working with more complex ways to define clusters. Further, the amortization networks can be trained using generated datasets where the ground truth clusterings are known. This can be interpreted as implicitly learning the definition of clusters underlying the training datasets, such that amortized inference (approximately) produces the appropriate clusterings. In a sense this shares a similar philosophy as Neural Processes (Garnelo et al., 2018b;a), which meta-learns from multiple datasets to learn a prior over functions.
In this paper, we build on these prior works and propose Deep Amortized Clustering (DAC). As in prior works, the amortization networks in DAC are trained using generated datasets where the ground truth clusterings are known. Like Lee et al. (2019), DAC uses a Set Transformer, but differs from Lee et al. (2019) in that it generates clusters sequentially, which enables to produce a varying number of clusters depending on the complexity of the dataset (Fig. 1). Our approach also extends Lee et al. (2019) from MOG to problems with more complex cluster definitions, which are arguably harder to hand specify and easier to meta-learn from data. Our work also differs from Pakman et al. (2019) in that our network processes data points in parallel while Pakman et al. (2019) processes them sequentially, which is arguably less scalable and limits applicability to smaller datasets.
This paper is organized as follows. We begin by describing in Section 2 the permutation-invariant set transformer modules that we use throughout the paper. In Section 3, we describe how we implement our core idea of identifying one cluster at a time, and describe our framework for clustering, the DAC There are several challenges in solving DAC on complex datasets, and we structured our paper roughly in order of difficulty. We apply DAC to clustering synthetic data (Section 5) and image data (Section 6); some settings required additional components, which we describe when needed.

heading: 2 A PRIMER ON SET TRANSFORMER AND AMORTIZED CLUSTERING
text: In this section, we briefly review the set-input neural network architectures to be used in the paper, and describe how Lee et al. (2019) used them to solve amortized clustering for MOG.

heading: 2.1 SET TRANSFORMER
text: The Set Transformer (ST) is a permutation-invariant set-input neural network that uses self-attetntion operations as building blocks. It utilizes multi-head attention (Vaswani et al., 2017) for both encoding elements of a set and decoding encoded features into outputs.
The fundamental building block of a ST is the Multihead Attention Block (MAB), which takes two sets X = [x1, . . . , xn]> and Y = [y1, . . . , ym]> and outputs a set of the same size as X . Throughout this article, we represent sets as matrices where each row corresponds to an element. An MAB is defined as
MAB(X,Y ) = H + rFF(H) where H = X + rFF(MultiheadAtt(X,Y )), (1)
where rFF(·) is a feed-forward layer applied row-wise (i.e., for each element). MAB(X,Y ) computes the pairwise interactions between the elements in X and Y with sparse weights obtained from attention. A Self-Attention Block (SAB) is simply MAB applied to the set itself: SAB(X) , MAB(X,X). We can model high-order interactions among the items in a set by stacking multiple SABs; we denote such a stack of L SABs applied to set X as SABL(X).
To summarize a set into a fixed-length representation, ST uses an operation called Pooling by Multihead Attention (PMA). A PMA is defined as PMAk(X) = MAB(S,X) where S = [s1, . . . , sk]> are trainable parameters.
Note that the time-complexity of SAB is O(n2) because of pairwise computation. To reduce this, Lee et al. (2019) proposed to use Induced Self-Attention Block (ISAB) defined as
ISAB(X) = MAB(X,MAB(I,X)), (2)
where I = [i1, . . . , im]> are trainable inducing points. ISAB indirectly compares the elements of X through the inducing points, reducing the time-complexity to O(nm). Similarly to the SAB, we write ISABL(X) to denote a stack of L ISABs.

heading: 2.2 AMORTIZED CLUSTERING WITH SET TRANSFORMER
text: Lee et al. (2019) presented an example using ST for amortized inference for a MOG. A dataset X is clustered by maximizing the likelihood of a k component MOG, and a ST is used to output the parameters as:
HX = ISABL(X), Hθ = PMAk(HX), (logitπj , θj) k j=1 = rFF(SABL′(Hθ)), (3)
where πj is the mixing coefficient and θj = (µj , σ2j ) are the mean and variance for the jth Gaussian component. The network is trained to maximize the expected log likelihood over datasets:
Ep(X) [ nX∑ i=1 log k∑ j=1 πj logN (xi;µj , σ2j ) ] , (4)
where nX is the number of elements inX . Clustering is then achieved by picking the highest posterior probability component for each data point under the MOG with parameters output by the ST.

heading: 3 DEEP AMORTIZED CLUSTERING
text: An apparent limitation of the model described in Section 2.2 is that it assumes a fixed number of clusters generated from Gaussian distributions. In this section, we describe our method to solve DAC in the more realistic scenario of having a variable number of clusters and arbitrarily complex cluster shapes.

heading: 3.1 FILTERING: INFERRING ONE CLUSTER AT A TIME
text: The objective (4) is not applicable when the number of clusters is not fixed nor bounded. A remedy to this is to build a set-input neural network f that identifies the clusters iteratively and make it to learn “when to stop”, similar to Adaptive Computation Time (ACT) for RNNs (Graves, 2016).
One may think of several ways to implement this idea (we present an illustrative example that simply augments ACT to ST in Section 5.1). Here we propose to train f to solve a simpler task - instead of clustering the entire dataset, focus on finding one cluster at a time. The task, what we call as filtering, is defined as a forward pass through f that takes a set X and outputs a parameter θ to describe a cluster along with a membership probability vector m ∈ [0, 1]nX where nX is the number of elements in X . The meaning of the parameter θ depends on the specific problem. For example, θ for MOG is (µ, σ2), the parameters of a Gaussian distribution. mi represents the probability of xi belonging to the cluster described by θ. To filter out the datapoints that belong to the current cluster, we use 0.5 as the threshold to discretize m to a boolean mask vector. The resulting smaller dataset is then fed back into the neural network to produce the next cluster and so on.
Minimum Loss Filtering Now we describe how to train the filtering network f . AssumeX has kX true clusters, and let y ∈ [1, . . . , kX ]nX be a cluster label vector corresponding to the true clustering of X . Then we define the loss function for one filtering iteration producing one θ and one m as
L(X, y,m, θ) = min j∈{1,...,kX}
( 1
nX nX∑ i=1 BCE(mi,1{yi=j})− 1 nX|j ∑ i|yi=j log p(xi; θ)
) , (5)
where nX|j := ∑nX i=1 1{yi=j}, BCE(·, ·) is the binary cross-entropy loss, and p(x; θ) is the density of x under cluster parameterised by θ. This loss encourages θ to describe the data distribution of a cluster, and m to specify which datapoints belong to this particular cluster. The rationale to take minimum across the clusters is follows. One way to train f to pick a cluster at each iteration is to impose an ordering on the clusters (e.g. in order of appearance in some arbitrary indexing of X , or in order of distance to origin), and to train f to follow this order. However, this may introduce unnecessary inductive biases that deteriorates learning. Instead, we let f find the easiest one to identify, thus promoting f to learn its own search strategy. Note that there are kX ! equally valid ways to label the clusters in X . This combinatorial explosion makes learning with standard supervised learning objectives for y tricky, but our loss (5) is inherently free from this problem while being invariant to the labelling of clusters.
We use the following architecture for the filtering network f : Section 2: encode data: HX = ISABL(X),
decode cluster: Hθ = PMA1(HX), θ = rFF(Hθ), decode mask: Hm = ISABL′(MAB(HX , Hθ)), m = sigmoid(rFF(Hm)). (6)
The network first encodesX intoHX and extracts cluster parameters θ. Then θ together with encoded data HX are further processed to produce the membership probabilities m. We call the filtering network with architecture (6) and trained with objective (5) Minimum Loss Filtering (MLF).
Anchored Filtering An alternative strategy that we found beneficial for harder datasets is to use anchor points. Given a dataset X and labels y constructed from the true clustering, we sample an anchor point with index a ∈ {1, . . . , nX} uniformly from X . We parameterize a set-input network f to take both X and a is input, and to output the cluster that contains the anchor point xa. The corresponding loss function is,
L(x, y, a,m, θ) = 1 nX nX∑ i=1 BCE(mi,1{yi=ja})− 1 nX|ja ∑ i|yi=ja log p(xi; θ), (7)
where ja denotes the the true cluster index containing a. The architecture to be trained with this loss can be implemented as
encode data: HX = ISABL(X), HX|a = MAB(HX , ha), decode cluster: Hθ = PMA1(HX|a), θ = rFF(Hθ),
decode mask: Hm = ISABL′(MAB(HX|a, Hθ)), m = sigmoid(rFF(Hm)), (8)
where ha is the row vector of HX corresponding to the index a. We train (8) by randomly sampling a for each step, and thus promoting f to find clusters by comparing each data point to the random anchor point. Note that the loss is also free from the label order ambiguity given anchor points. We call this filtering strategy Anchored Filtering (AF).

heading: 3.2 BEYOND SIMPLE PARAMETRIC FAMILIES
text: When each cluster cannot be well described by a Gaussian or other simple parametric distributions, we have several choices to learn them. The first is to estimate the densities along with the filtering using neural density estimators such as Masked Autoregressive Flow (MAF) (Papamakarios et al., 2017). Another option is to lower-bound log p(x; θ) by introducing variational distributions, for example using Variational Autoencoder (VAE) (Kingma & Welling, 2014). See Section 5.2 and Section 6.1 for examples. If the density estimation is not necessary, we can choose not to learn log p(x; θ). In other words, instead of (5) and (7), we train
L(X, y,m, θ) = min j nX∑ i=1 BCE(mi,1{yi=j}), L(X, y, a,m, θ) = nX∑ i=1 BCE(mi,1{yi=ja}), (9)
for MLF and AF, respectively. The corresponding architectures are (6) and (8) with parameter estimation branches removed. The DAC trained in this way implicitly learns how to define a cluster from the given training datasets and cluster labels. See Section 6.2 and Section 6.3 where we applied this to cluster image datasets.

heading: 3.3 DEEP AMORTIZED CLUSTERING
text: Recall that each step of filtering yields one cluster. To solve DAC, we iterate this procedure until all clusters are found. After each filtering step, we remove from the dataset the points that were assigned to the cluster, and perform filtering again. This recursive procedure is repeated until all datapoints have been assigned to a cluster1. We call the resulting amortized clustering algorithm as DAC2. DAC learns both data generating distributions and cluster assignment distributions from meta-training datasets without explicit hand-engineering.

heading: 4 RELATED WORKS
text: Deep clustering methods There is a growing interest in developing clustering methods using deep networks for complex data (Yang et al., 2016a;b; Xie et al., 2015; Li et al., 2017; Ji et al., 2018). See Aljalbout et al. (2018) for a comprehensive survey on this line of work. The main
1 In practice, we input the entire dataset along with m and assign zero attention weight to datapoints with mi = 1. This is equivalent to the described scheme, but has the added benefit of being easy to parallelize across multiple datasets.
2Note that DAC with MLF is not stochastic once we discretize the membership probability.
focus of these methods is to learn a representation of input data amenable to clustering via deep neural networks. Learning representations and assigning data points to the clusters are usually trained alternatively. However, like the traditional clustering algorithms, these methods aim to cluster particular datasets. Since such methods typically learn a data representation using deep neural networks, the representation is prone to overfitting when applied to small datasets.
Learning to Cluster Learning to cluster refers to the task of learning a clustering algorithm from data. Such methods are trained in a set of source datasets and tested on unseen target datasets. Constrained Clustering Networks (Hsu et al., 2017; 2019) follow a two-step process for learning to cluster: they first learn a similarity metric that predicts whether a given pair of datapoints belong to the same class, and then optimize a neural network to predict assignments that agree with the similarity metric. Centroid Networks (Huang et al., 2019) learn an embedding which is clustered with the Sinkhorn K-means algorithm. While these methods combine deep networks with an iterative clustering algorithm, our framework is much more efficient as it directly identifies each cluster after one forward pass. Our experiments in Section 6 that our model is orders of magnitude faster than previous works in learning to cluster.
Amortized clustering methods To the best of our knowledge, the only works that consider a similar task to ours is Lee et al. (2019) and Pakman et al. (2019). We refer the reader back to Section 2 for an outline of the amortized clustering framework presented in Lee et al. (2019). Pakman et al. (2019) presented an amortized clustering method called Neural Clustering Process (NCP). Given a dataset, NCP sequentially computes the conditional probability of assigning the current data point to one of already constructed clusters or a new one, similar in spirit to the popular Gibbs sampling algorithm for Dirichlet process mixture models (Neal, 2000), but without positing particular priors on partitions, but rather letting the network learn from data. However, the sequential sampling procedure makes the algorithm not parallizable using modern GPUs, limiting its scalability. Furthermore, since the clustering results vary a lot w.r.t. the sequential processing order, the algorithm needs a sufficient number of random samples to get stable clustering results. We compared our method to NCP on small-scale MOG experiments in Appendix C, and our results support our claim.

heading: 5 EXPERIMENTS ON SYNTHETIC DATASETS

heading: 5.1 2D MIXTURE OF GAUSSIANS
text: We first demonstrate DAC with MLF on 2D MOG datasets with arbitrary number of clusters. We considered two baselines that can handle variable number of clusters: truncated Variational Bayesian Dirichlet Process Mixture Model (VBDPM) (Blei & Jordan, 2006) and the ST architecture (Lee et al., 2019) with ACT-style decoder so that it can produce arbitrary number of clusters. We describe the latter method, ACT-ST, in detail in Appendix A. See Appendix B for detailed experimental setup including data generation process and training scheme. We trained DAC and ACT-ST using random datasets with a random number of data points n ≤ nmax and clusters k ≤ kmax, where we set (nmax, kmax) = (1000, 4) during training. We tested the resulting model on two scenarios. The first one is to test one same configurations; testing on 1,000 random datasets with (nmax, kmax) = (1000, 4). The second one is test on 1,000 random datasets with (nmax, kmax) = (3000, 12) to see whether the amortized clustering methods can generalize to an unseen number of clusters. For both scenarios, we ran VBDPM on each test dataset until convergence from scratch. We used the mean of the variational distributions as the point-estimates of the parameters to compute log-likelihoods. Table 1 summarizes the results. DAC works well for both cases, even beating the oracle log-likelihood computed from the true parameters, while ACT-ST fails to work in the more challenging (nmax, kmax) = (3000, 12) case (Fig. 2). VBDPM works well for both, but it takes considerable time to converge whereas DAC requires no such optimization to cluster test datasets.

heading: 5.2 2D MIXTURE OF WARPED GAUSSIANS
text: When the parametric form of cluster distribution is not known, we cannot directly compute the log p(xi; θ) term in (5). In this case, we propose to estimate the density p(x; θ) via neural density estimators along with the DAC learning framework. We construct each cluster by first sampling points from a 2D unit Gaussian distribution, and then applying a random nonlinear transformation on
each point. We use MAF (Papamakarios et al., 2017) to model p(x; θ) where θ is a context vector that summarizes the information about a cluster. We trained the resulting DAC with MLF using random datasets, and compared to spectral clustering (Shi & Malik, 2000). As shown in Fig. 3, DAC finds and estimates the densities of these nonlinear clusters. See Appendix D for more details and results.

heading: 6 EXPERIMENTS ON REAL DATASETS

heading: 6.1 CLUSTERING EMNIST WITH MIXTURE OF NEURAL STATISTICIANS
text: We may approximate the likelihood p(x; θ) via a VAE (Kingma & Welling, 2014) when the data distribution is too high-dimensional or complex. Instead of directly maximizing the log-likelihood, we maximize a lower-bound on the likelihood, log p(x; θ) ≥ Eq(z|x;θ)[log p(x, z; θ) − q(z|x; θ)], where θ encodes the context of a cluster and z is a latent variable that describes x based on θ. Neural Statistician (NS) (Edwards & Storkey, 2016) proposed the idea of approximating p(x; θ) using a context θ produced by a set network; we thus call this model a mixture of NSs. We found that the DAC implemented in this way could cluster well, generalizes to an unseen number of clusters, and generate images conditioned on the cluster context θ. See Appendix E for detailed results.

heading: 6.2 CLUSTERING EMBEDDED IMAGENET
text: We applied DAC to cluster the collection of miniImageNet (Vinyals et al., 2016) and tieredImageNet (Ren et al., 2018). We gathered pretrained 640 dimensional features of the images released by Rusu et al. (2018)3. We used the training and validation features as training set and test features as test set. The resulting training set contains 620,000 samples from 495 classes, and the test set contains 218,000 samples from 176 classes, with no overlap between training and test classes.
We trained DAC without density estimations (9), using both MLF and AF. We sampled randomly clustered datasets from the training set having (nmax, kmax) = (100, 4). We then generated 1,000 randomly clustered datasets from the test set with (nmax, kmax) = (300, 12). We compared DAC to basic clustering algorithms (k-means, spectral clustering), Deep Embedding Clustering (DEC) (Xie et al., 2015), and transfer learning methods (KCL (Hsu et al., 2017) and MCL (Hsu et al., 2019)). k-means, spectral, and DEC were trained for each test dataset from scratch. For KCL and MCL, we first trained a similarity prediction network using the training set, and used it to cluster each test dataset. For DEC, KCL and MCL, we used fully-connected layers with 256 hidden units and 3 layers for both similarity prediction and clustering network. Note that the size of the test datasets are small (nmax = 300 < 640), so one can easily predict that DEC, KCL, and MCL would overfit. The algorithms other than ours was given the true number of clusters. The results are summarized in Table 2. It turns out that the pretrained features are good enough for the basic clustering algorithms to show decent performance. The deep learning based methods failed to learn useful representations due to the small dataset sizes. Ours showed the best clustering accuracies while also consuming the shortest computation time.

heading: 6.3 CLUSTERING OMNIGLOT IMAGES
text: We apply our filtering architecture to the unsupervised cross-task transfer learning benchmark of Hsu et al. (2017; 2019). This benchmark uses the Omniglot dataset (Lake et al., 2015) to measure how well a clustering method can generalize to unseen classes. The Omniglot dataset consists of
3https:github.com/deepmind/leo
handwritten characters from 50 different alphabets. Each alphabet consists of several characters, and each character has 20 images drawn by different people. Our problem setup consists of training a clustering model using images from the 30 background alphabets, and using each of the 20 alphabets as a seperate dataset to test on. We use the same VGG network backbone as in Hsu et al. (2019) and follow their experimental setup.
We show the normalized mutual information (NMI) of DAC along with other methods in Table 3. While previous methods were also evaluated on the easier setting where the true number of clusters is given to the network, this setting is not applicable to DAC. We see that DAC is competitive with the state-of-the-art on this challenging task despite requiring orders of magnitude less computation time. While the metrics for DAC were computed after at most 100 forward passes, previous methods all require some sort of iterative optimization. For example, KCL and MCL (Hsu et al., 2017; 2019) required more than 100 epochs of training for each alphabet to arrive at the cluster assignments in Table 3. This difference in computation requirements is more clearly demonstrated in Table 4: DAC requires an average of less than 5 seconds per alphabet whereas KCL and MCL required more than 100. Table 4 additionally shows that in addition to being extremely time-efficient, DAC was more accurate in estimating k. This demonstrates the efficacy of our overall structure of identifying one cluster at a time.

heading: 7 DISCUSSION AND FUTURE WORK
text: We have proposed DAC, an approach to amortized clustering using set-input neural networks. DAC learns to cluster from data, without the need for specifying the number of clusters or the data generating distribution. It clusters datasets efficiently, using a few forward passes of the dataset through the network.
There are a number of interesting directions for future research. The clustering results produced by DAC is almost deterministic because we discretise the membership probabilities in the filtering process. It would be interesting to take into account uncertainties in cluster assignments. In the imagenet experiment, we found that we needed a sufficient number of training classes to make DAC generalize to unseen test classes. Training DAC to generalize to unseen image classes with smaller numbers of training classes seem to be a challenging problem. Finally, learning DAC along with state-of-the-art density estimation techniques for images in each cluster is also a promising research direction.

heading: A DETAILED DESCRIPTION OF ACT-ST
text: We first define an adaptive-computation-time version of PMA,
aPMA(X, k) = MAB([s1, . . . , sk] >, X), sj = PMA1([s1, . . . , sj−1] >) for j = 2, . . . , k, (10)
which enables an RNN-like iterative computation by sequentially extending the parameters for PMA. The clustering network to output variable number of parameters is then defined as
HX = ISABL(X), H (k) θ = SABL′(aPMA(H, k)),
vk = sigmoid(mean(rFF(H (k) θ [:,1]))), sk = 1− ∏ j≤k vk,
(logit π(k)j , θ (k) j ) k j=1 = rFF(H (k) θ [:,2:]), (11)
where [:,1] and [:,2:] are numpy-like notation indexing the columns. sk is a “stop” variable where sk > 0.5 means the iteration stops at kth step and continues otherwise.
During training, we utilize the true number of clusters as supervision for training ck, yielding the overall loss function
Ep(X,ktrue) [ − nX∑ i=1 log ktrue∑ j=1 π(ktrue)j p(xi; θ (ktrue) j ) + kmax∑ k=1 BCE(ck,1{k<ktrue}) ] . (12)
where ktrue is the true number of clusters, kmax ≥ ktrue is maximum number of steps to run.

heading: B DETAILS OF MOG EXPERIMENTS
text: We generated dataset by the following process.
n ∼ Unif(0.3nmax, nmax), k − 1 ∼ Binomial(kmax − 1, 0.5), π ∼ Dir(α k︷ ︸︸ ︷
[1, . . . , 1]), (yi) n i=1 i.i.d.∼ Cat(π)
(µj) k j=1 i.i.d.∼ Normal([0, 0]>, 9I), (σj)kj=1 i.i.d.∼ log Normal(log(0.25)[1, 1]>, 0.01I),
xi ∼ Normal(µyi ,diag(σ2yi)) for i = 1, . . . , n. (13)
Both ACT-ST and filtering networks were trained with nmax = 1, 000 and kmax = 4. For each step of training, we sampled a batch of 100 datasets (sharing the same n ∼ Unif(0.3nmax, nmax) to comprise a tensor of shape 100 × n × 2), and computed the stochastic gradient to update parameters. We trained the networks for 20,000 steps using ADAM optimizer (Kingma & Ba, 2015) with initial learning rate 5× 10−4. The results in Table 1 are obtained by testing the trained models on randomly generated 1,000 datasets with the same generative process.

heading: C COMPARISON TO NEURAL CLUSTERING PROCESS
text: We compare DAC to NCP. Due to the sequential nature, the training procedure of NCP does not scale to the other experiments we conducted. Instead, we trained NCP for MOG data described in Appendix B with smaller scale having nmax = 100 and kmax = 4. We used the code released by the authors4 with default hyperparameters. We measured the clustering performance for 100 random datasets generated with (nmax, kmax) = (3000, 12) (Table 5). Both method generalized well w.r.t. the number of data points n, but filtering did much better in generalizing for the number of clusters k. The performance of NCP for clustering depends heavily on the processing order, so we conducted multiple runs with different random orders and picked the best one w.r.t. the clustering probability computed from NCP. Ours outperformed NCP with S = 50 samples per dataset with at least two orders of magnitude faster processing time.

heading: D DETAILS OF MIXTURE OF MAFS AND WARPED GAUSSIAN EXPERIMENTS
text: We model the cluster density as MAF.
log p(x; θ) = log p(x1) + d∑ i=2 log p(xi|x1:i−1; θ)
= logNormal(x1|0, 1) + d∑ i=2 log Normal(xi|µ(x1:i−1, θ), σ2(x1:i−1, θ))
= logNormal(u|0d, Id)− d∑ i=2 log σ(x1:i−1, θ), (14)
where
u1 = x1, ui = xi − µi(x1:i−1, θ) σ(x1:i−1, θ) . (15)
We can efficiently implement this with MADE (Germain et al., 2015).
4https://github.com/aripakman/neural_clustering_process
We generated the warped Gaussian datasets by the following generative process.
n ∼ Unif(0.3nmax, nmax), k − 1 ∼ Binomial(kmax − 1, 0.5), π ∼ Dir(α k︷ ︸︸ ︷
[1, . . . , 1]), (yi) n i=1 i.i.d.∼ Cat(π) r̃ ∼ MoG1(y), r = 0.8πr̃,
(aj) k j=1 i.i.d.∼ Normal(0, √ 2), (bj) k j=1 i.i.d.∼ Normal(0, √ 2) si = ayi cos ri + 0.1 byi cos ri√ a2yi + b 2 yi , ti = byi sin ri + 0.1 ayi sin ri√ a2yi + b 2 yi ,
(%j) k j=1 i.i.d.∼ Unif(0, 2π), Ri = [ cos %yi − sin %yi sin %yi cos %yi ] ,
(λj) k j=1 i.i.d.∼ Normal(min(k, 4.0)[1, 1]>, I), xi = Ri[si, ti]> + λyi , (16)
where MoG1(y) denotes the sampling from 1d Mixture of Gaussians with the same parameter distributions as (13).
The filtering network is constructed as (6) where θ is a 128 dimensional vector to be fed into MAF as a context vector for a cluster. We implemented log p(x; θ) as a 4 blocks of MAF with MADE (Germain et al., 2015). The filtering network was trained using random datasets with nmax = 1, 000 and kmax = 4, and trained for 20,000 steps with ADAM optimizer. We set initial learning rate as 5 · 10−4. Table 6 compares the resulting DAC to spectral clustering (Shi & Malik, 2000). Spectral clustering was ran for each dataset from scratch with true number of clusters given. To give a better idea how good is the estimated log-likelihood values, we trained MAF with same structure (4 blocks of MADE) but without mixture component and cluster context vectors for 100 random test datasets. We trained for 20,000 steps for each dataset using ADAM optimizer with learning rate 5 · 10−4. The log-likelihood values estimated with filtering on the same datasets outperforms the one obtained by exhaustively training MAF for each dataset, and got -2.570 for MAF and -2.408 for DAC. This shows that the amortized density estimation works really well.

heading: E DETAILS OF MIXTURE OF NEURAL STATISTICIANS AND EMNIST EXPERIMENTS
text: E.1 MIXTURE OF NEURAL STATISTICIANS
Let X = [x1, . . . , xn]> be an input set. We construct a filtering network as follows.
henc,i = Encoder(xi) for i = 1, . . . , n, HX = ISABL([henc,1, . . . , henc,n]>), Hθ = PMA1(HX), θ = rFF(Hθ), zi ∼ q(zi|henc,i, θ) for i = 1, . . . , n hdec,i = Decoder(zi, θ) for i = 1, . . . , n, x̃i ∼ p(xi|hdec,i) for i = 1, . . . , n Hm = ISABL(MAB(HX , Hθ)), m = sigmoid(rFF(Hm)). (17)
The log-likelihood for a particular cluster log p({xi|yi = j}; θ) is then approximate by the variational lower-bound,
log p({xi|yi = j}; θ) ≥ ∑ i|yi=j ∫ q(zi|henc,i, θ) log p(xi|hdec,i)p(zi) q(zi|henc,i, θ) dzi
= ∑ i|yi=j ( Eq(zi|henc,i,θ))[log p(xi|hdec,i)]−KL[q(zi|henc,i, θ)‖p(zi)] ) . (18)
Once the clustering is done, the likelihood of the whole dataset X can be lower-bounded as
log p(X; θ1, . . . , θk) ≥ k∑ j=1 πj log p({xi|yi = j}; θj). (19)
The likelihood lower-bounding for each cluster corresponds to the NS except for that the context vector is constructed with ISAB and PMA, so we call this model a mixture of NSs.
E.2 EXPERIMENTS ON EMNIST DATA
We trained the model described in (17) to EMNIST (Cohen et al., 2017). We picked “balanced” split, with 47 class / 112,800 training images / 18,800 test images. At each training step, we generated 10 randomly clustered dataset with (nmax, kmax) = (1000, 4) and trained the network by the loss function (5) with the log-likelihood part replaced by (18). For Encoder(xi) and Decoder(zi, θ), we used three layers of multilayer perceptrons. For the variational distribution q(zi|henc,i, θ), we used Gaussian distribution with parameters constructed by a fully-connected layer taking [henc,i, θ] as inputs. Following Chen et al. (2017), We used an autoregressive prior distribution constructed by MAF for p(z). For the likelihood distribution, p(x|hdec,i), we used Bernoulli distribution. Each training image was stochastically binarized.
Table 7 shows that iterative filtering can decently cluster EMNIST. Fig. 6 shows that given a set of 100 images with 4 clusters, the filtering can correctly identify a cluster and learns the generative model to describe it. Fig. 7 shows the clustering results using iterative filtering for 100 images.

heading: F MORE RESULTS FOR OMNIGLOT EXPERIMENTS
text: We present more detailed comparion of KCL, MCL and ours for each alphabet.
In c
lu st
er
Ge ne
ra te
d No
t i n
clu st
er
Fi gu
re 6:
A st
ep of
fil te
rin g
fo r1
00 EM
N IS
T im
ag es
w ith
4 cl
us te
rs .(
Le ft)
im ag
es be
lo ng
to th
e cl
us te
ri de
nt ifi
ed by
th e
fil te
rin g
st ep
.( M
id dl
e) Im
ag es
ge ne
ra te
d by
de co
di ng
ra nd
om la
te nt
ve ct
or s z ∼ p (z )
pa ss
ed th
ro ug
h th
e de
co de
r, w
ith cl
us te
rc on
te xt
ve ct
or ex
tra ct
ed fr
om th
e fil
te rin
g st
ep .(
R ig
ht )I
m ag
es do
no tb
el on
g to
th e
cl us
te ri
de nt
ifi ed
th e
fil te
ri ng
st ep
.

Review summaries:
The paper presents an amortized clustering method, called DAC, which is a neural architecture that allows efficient data clustering using a few forward passes. The proposed method is essentially based on the idea behind set-input neural networks [1], which consists of modeling the interaction between instances within a given dataset. Compared with the previous work [1], the main difference is that DAC does not need to specify the number of clusters, as in the case of Bayesian nonparametrics, making it more flexible for clustering complex datasets. It is empirically shown that DAC can efficiently and accurately cluster new datasets coming from the same distribution for both synthetic and image data.

In this paper, the authors proposed a new clustering method called deep amortized clustering (DAC). Inspired by Lee et al 2019, the authors exploited a transformer to gather the contextual information across different dataset points and then predict the cluster label for each data point. The main difference from Lee et al is that the proposed DAC sequentially estimate the cluster labels for the data points and thus more flexible to estimate the number of clusters in the whole dataset. Based on the proposed DAC method, the authors evaluated the performance on both unsupervised clustering and supervised clustering tasks. it turns out the proposed method has achieved better or comparable performance to previous work on various datasets while hold less computational cost.