Conditional Distribution Quantization in Machine Learning Blaise Delattre, Sylvain Delattre, Alexandre Vérine, Alexandre Allauzen Abstract Conditional expectation 𝔼 ⁡ ( Y ∣ X ) \mathbb{E}(Y\mid X) often fails to capture the complexity of multimodal conditional distributions ℒ ⁡ ( Y ∣ X ) \mathcal{L}(Y\mid X) . To address this, we propose using n n -point conditional quantizations—functional mappings of X X that are learnable via gradient descent—to approximate ℒ ⁡ ( Y ∣ X ) \mathcal{L}(Y\mid X) . This approach adapts Competitive Learning Vector Quantization (CLVQ), tailored for conditional distributions. It goes beyond single-valued predictions by providing multiple representative points that better reflect multimodal structures. It enables the approximation of the true conditional law in the Wasserstein distance. The resulting framework is theoretically grounded and useful for uncertainty quantification and multimodal data generation tasks. For example, in computer vision inpainting tasks, multiple plausible reconstructions may exist for the same partially observed input image X X . We demonstrate the effectiveness of our approach through experiments on synthetic and real-world datasets. † † affiliationnotice: Equal contribution 1 Introduction When analyzing the relationship between random variables X and Y , the conditional expectation \mathbb{E}(Y\mid X) is often used as a summary statistic to describe Y given X . However, for multimodal or complex conditional distributions, \mathbb{E}(Y\mid X) may fail to capture critical information about the underlying distribution. For instance, consider a case where: \mathbb{P}(Y=X+100\mid X)=\frac{1}{2},\quad\mathbb{P}(Y=X-100\mid X)=\frac{1}{2}, then: \mathbb{E}(Y\mid X)=X,\quad\text{but}\quad{\mathcal{L}}(Y\mid X)=\frac{1}{2}\delta_{X+100}+\frac{1}{2}\delta_{X-100}. where \delta stands for Dirac mass. While the expectation \mathbb{E}(Y\mid X) returns X , the true conditional law {\mathcal{L}}(Y\mid X) reveals a richer, multimodal structure that is entirely missed by relying solely on the mean. This limitation has important implications for downstream tasks, particularly in uncertainty quantification for image restoration models used in safety-critical domains such as autonomous driving and biological imaging. Many existing approaches rely on per-pixel estimates, such as variance heatmaps ( Kendall and Gal, 2017 ) or confidence intervals ( Angelopoulos et al., 2022 ) to visualize uncertainty. While these methods provide valuable insights, they can struggle to represent structured uncertainty, overlooking spatial correlations between neighboring pixels. Bishop (1994) ’s work underscores this limitation, showing that conditional expectation works well when Y lies in a corner of the simplex but often fails in other contexts. Instead, Bishop proposes a Mixture Density Networks, which model the full conditional distribution, allowing for a richer representation of Y given X . More recent works utilize PCA on the conditional distribution to model uncertainty in image reconstruction ( Nehme et al., 2023 ; Manor and Michaeli, 2024 ) . These approaches focus on identifying the dominant modes of variation (principal components) to capture uncertainty. However, they are local methods, analyzing variability only around the conditional mean. To address this limitation, we propose approximating {\mathcal{L}}(Y\mid X) using n -point quantizations that adapt to X . Our approach, termed Conditional Competitive Learning Vector Quantization (CCLVQ), extends Competitive Learning Vector Quantization ( Bouton and Pagès, 1997 ; Kohonen, 1995 ) to conditional distributions. In this framework, the n -point representations are functional mappings \{f_{i}\}_{i=1}^{n} of X , enabling flexible and expressive summaries of Y while capturing multimodal structures. In particular, the f_{i} can be parameterized as deep neural networks. Our contributions are: • Theoretical Foundation of CCLVQ: We extend CLVQ to conditional distributions and provide theoretical guarantees for quantizing {\mathcal{L}}(Y\mid X) with adaptive representations. • Algorithm Design: We propose an efficient training algorithm for CCLVQ that learns an ensemble of experts to collaboratively partition the output space. • Uncertainty Quantification in Image Restoration and Generation: We apply CCLVQ to uncertainty quantification tasks, such as inpainting and denoising, capturing the multimodal nature of {\mathcal{L}}(Y\mid X) and providing diverse, plausible reconstructions with quantitative uncertainty. We also apply the method to improve quality and diversity in generative models. 2 Related Works Understanding and modeling uncertainty in deep learning has been a long-standing challenge, with various approaches proposed to quantify and manage uncertainty across tasks. Pixel-based approaches Pixel-wise uncertainty quantification methods, such as per-pixel variance heatmaps ( Kendall and Gal, 2017 ) , confidence intervals ( Angelopoulos et al., 2022 ) , and conformal prediction masks ( Kutiel et al., 2023 ) , often neglect spatial correlations between pixels, resulting in overconfident predictions and limited diversity in reconstructions. Many of these methods rely on Bayesian approaches ( Gal and Ghahramani, 2016 ; Blundell et al., 2015 ) , which, while theoretically sound, are computationally intensive and difficult to scale. Methods that explore the conditional distribution by producing diverse reconstructions while accounting for pixel correlations are essential. PCA-based approaches Building on the idea of exploring conditional distributions, Principal Component Analysis (PCA) provides a form of uncertainty quantization ( Nehme et al., 2023 ; Manor and Michaeli, 2024 ) that focuses on variability around the conditional mean \mathbb{E}(Y\mid X) . A similar method has been used to regularize the top principal components of the conditional covariance for enhanced posterior sampling in generation with GANs ( Bendel et al., 2024 ) . However, PCA-based methods face critical limitations: they capture only linear dependencies and local variability, neglecting global or non-linear structures. This makes them inherently unsuited for modeling multimodal distributions. Furthermore, PCA assumes unimodal variability, quantifying uncertainty in \ell_{2} -norm around the mean, which restricts their ability to provide diverse reconstructions. Ensemble of Experts Deep Ensembles ( Lakshminarayanan et al., 2017 ) provide a scalable alternative by training multiple independent networks, combining their outputs to capture both epistemic and aleatoric uncertainty, demonstrating robustness to dataset shifts and well-calibrated predictions. Mixture Density Networks (MDN) ( Bishop, 1994 ) predict the parameters of a mixture distribution, enabling them to capture multimodal outputs and quantify predictive uncertainty effectively. This makes them particularly suitable for tasks where the conditional distribution \mathcal{L}(Y\mid X) is complex or multimodal. MDNs approximate complex distributions by predicting the parameters of probabilistic mixtures, while quantization methods achieve a similar goal by representing the distribution with a finite set of adaptive points. Multiple Choice Learning MCL was introduced by Guzman-Rivera et al. (2012) to address prediction under ambiguity by training n predictors jointly with a winner-takes-all (WTA) assignment strategy. Subsequent extensions have aimed at improving stability and diversity: stochastic MCL (sMCL) ( Lee et al., 2016 ) performs batch-wise assignments, confident MCL (cMCL) ( Lee et al., 2017 ) adds an entropic regularization to encourage uniform usage of predictors, and Rupprecht et al. (2017) provides a probabilistic interpretation of MCL through mixture modeling. More recently, resilient MCL (rMCL) ( Letzelter et al., 2023 ) introduces a learned scoring scheme for hypothesis selection, underpinned by a Voronoi-based probabilistic framework to preserve output diversity. Annealed MCL ( Perera et al., 2024 ) further extends MCL by introducing an annealing schedule that gradually relaxes WTA constraints during training, thus improving optimization stability. More recently, the work of Letzelter et al. (2024) explores the probabilistic interpretation of Winner-Takes-All (WTA) training, highlighting its connection to conditional density estimation, which is close to the work in this paper. In parallel, implicit generative models offer alternative strategies for modeling multimodality. Implicit Maximum Likelihood Estimation (IMLE) ( Li and Malik, 2019 ) avoids explicit likelihoods by matching real samples to generated outputs, ensuring distributional coverage and preventing mode collapse. CHIMLE ( Peng et al., 2022 ) extends this idea to conditional generation through a hierarchical formulation, synthesizing diverse outputs in complex multimodal tasks. These methods provide complementary approaches to ambiguity modeling: MCL emphasizes deterministic expert selection, whereas IMLE-based techniques leverage stochasticity to ensure coverage of the output space. Quantization methods Lloyd’s K-means algorithm ( Lloyd, 1982 ) is a foundational quantization method that iteratively minimizes the distortion between data points and their nearest centroids by alternating between assignment and update steps. While effective, it requires exhaustive traversal of the dataset in each iteration, making it computationally expensive for large-scale data. Extensions of K-means, such as Competitive Learning Vector Quantization (CLVQ) ( Kohonen, 1995 ; Bouton and Pagès, 1997 ) , focus on adaptively learning quantization points through a competitive process. In the following, we propose a method based on CLVQ, resembling an ensemble of experts, providing a recipe for training diverse networks to quantize simply the conditional distribution. 3 Background Here, we present some well-known results, including the proofs showing the extent to which the quantization of a random vector provides an approximation of its distribution for the Wasserstein distance with a distribution with finite support. Refer to ( Graf and Luschgy, 2000 ) or ( Pagès, 2015 ) for more details. 3.1 Wasserstein distance The Wasserstein distance of order 2 between two distributions \mu and \nu on \mathbb{R}^{d} is defined as {\mathcal{W}}_{2}(\mu,\nu)=\inf_{Y_{1}\sim\mu,Y_{2}\sim\nu}\Bigl(\mathbb{E}\Bigl(\lvert Y_{1}-Y_{2}\rvert^{2}\Bigr)\Bigr)^{1/2} where the infimum is taken over all pairs of d -dimensional random vectors Y_{1} and Y_{2} marginally distributed as \mu and \nu , respectively. Here, \lvert\cdot\rvert denotes the Euclidean norm on \mathbb{R}^{d} . As long as \mu and \nu have finite second moments, {\mathcal{W}}_{2}(\mu,\nu) is finite. The Wasserstein distance is a powerful metric between probability measures. Unlike measures such as total variation or Kullback-Leibler divergence, it respects the geometry of the underlying space \mathbb{R}^{d} , making it particularly meaningful in applications requiring geometric fidelity ( Peyré and Cuturi, 2019 ) . 3.2 Vector Quantization to approximate a distribution Let Y be a random vector with values in \mathbb{R}^{d} and let n\geq 1 , an integer. We denote by |\cdot| the Euclidean norm on \mathbb{R}^{d} . Vector quantization, including methods like k -means and Learning Vector Quantization (LVQ), aims to minimize the functional D_{n}(\alpha)=\mathbb{E}\Bigl[\min_{1\leq i\leq n}\bigl\lvert Y-\alpha_{i}\bigr\rvert^{2}\Bigr], where \alpha=(\alpha_{1},\dots,\alpha_{n})\in(\mathbb{R}^{d})^{n} represents the quantizer. We assume that \mathbb{E}(\lvert Y\rvert^{2})<\infty so that D_{n}(\alpha)<\infty for every \alpha . This functional arises naturally in applications such as signal transmission, clustering, and numerical integration ( Pagès, 2015 ) . For a given quantizer \alpha\in(\mathbb{R}^{d})^{n} , one chooses a closest neighbor projection \pi_{\alpha}:\mathbb{R}^{d}\to\{\alpha_{1},\dots,\alpha_{n}\} that is a map such that, for all y\in\mathbb{R}^{d} , \pi_{\alpha}(y)\in\{\alpha_{1},\dots,\alpha_{n}\}\ \text{and}\ |y-\pi_{\alpha}(y)|=\min_{1\leq i\leq n}|y-\alpha_{i}| (1) This choice specifies how ties are broken. The induced \alpha -quantization of Y is the random vector \pi_{\alpha}(Y) and we have D_{n}(\alpha)=\mathbb{E}\Bigl[\bigl\lvert Y-\pi_{\alpha}(Y)\bigr\rvert^{2}\Bigr]. Consequently, the Wasserstein distance of order 2 between the distribution of Y and \pi_{\alpha}(Y) satisfies \mathcal{W}_{2}\bigl(\mathcal{L}(Y),\mathcal{L}(\pi_{\alpha}(Y))\bigr)\leq D_{n}(\alpha)^{1/2}. (2) Moreover, \mathcal{L}(\pi_{\alpha}(Y)) can be expressed as a weighted sum: \mathcal{L}(\pi_{\alpha}(Y))=\sum_{i=1}^{n}\mathbb{P}(\pi_{\alpha}(Y)=\alpha_{i})\delta_{\alpha_{i}}, allowing for practical approximations of \mathcal{L}(Y) through estimated weights \mathbb{P}(\pi_{\alpha}(Y)=\alpha_{i}) . We have more than the upper bound ( 2 ): D_{n}(\alpha)^{1/2} is the Wasserstein distance of {\mathcal{L}}(Y) to {\mathcal{L}}(\pi_{\alpha}(Y)) and is also the Wasserstein distance of {\mathcal{L}}(Y) to the set of distributions with support in \{\alpha_{1},\dots,\alpha_{n}\} . Proposition 3.1 . For every \alpha\in(\mathbb{R}^{d})^{n} we have \mathcal{W}_{2}\bigl(\mathcal{L}(Y),\mathcal{L}(\pi_{\alpha}(Y))\bigr)=D_{n}(\alpha)^{1/2}\\ =\min_{\nu\in\mathcal{P}(\alpha_{1},\dots,\alpha_{n})}{\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr) where \mathcal{P}(\alpha_{1},\dots,\alpha_{n}) denotes the set of distributions with support in the set \{\alpha_{1},\dots,\alpha_{n}\} . Proof. In view of the upper bound ( 2 ), it suffices to prove that {\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr)\geq D_{n}(\alpha)^{1/2} for every \nu\in\mathcal{P}(\alpha_{1},\dots,\alpha_{n}) . Let \nu\in\mathcal{P}(\alpha_{1},\dots,\alpha_{n}) . If \tilde{Y} and \hat{Y} are random vectors with values in \mathbb{R}^{d} such that {\mathcal{L}}(\tilde{Y})={\mathcal{L}}(Y) and {\mathcal{L}}(\hat{Y})=\nu , then \mathbb{P}(\hat{Y}\in\{\alpha_{1},\dots,\alpha_{n}\})=1 which implies \mathbb{E}\bigl(\lvert\tilde{Y}-\hat{Y}\rvert^{2}\bigr)\geq\mathbb{E}\bigl(\min_{1\leq i\leq n}\lvert\tilde{Y}-\alpha_{i}\rvert^{2}\bigr)=D_{n}(\alpha) ∎ 3.3 About optimal quantizers There exists at least one optimal quantizer, that is \alpha^{*}\in(\mathbb{R}^{d})^{n} such that D_{n}(\alpha^{*})=\inf_{\alpha\in(\mathbb{R}^{d})^{n}}D_{n}(\alpha), see ( Pagès, 2015 ) for a proof. The following result shows why it is worth minimizing D_{n} : Proposition 3.2 . If \alpha^{*} is optimal, one has \mathcal{W}_{2}\bigl({\mathcal{L}}(Y),{\mathcal{L}}(\pi_{\alpha^{*}}(Y))\bigr)=D_{n}(\alpha^{*})^{1/2}\\ =\min_{\nu\in\mathcal{P}_{n}(\mathbb{R}^{d})}{\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr) where \mathcal{P}_{n}(\mathbb{R}^{d}) denotes the set of distribution on \mathbb{R}^{d} whose support has a cardinality smaller than n . Proof. From Proposition 3.1 one gets D_{n}(\alpha^{*})^{1/2}=\min_{\alpha\in(\mathbb{R}^{d})^{n}}\min_{\nu\in\mathcal{P}(\alpha_{1},\dots,\alpha_{n})}{\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr), and moreover, since \bigcup_{\alpha}\mathcal{P}(\alpha_{1},\dots,\alpha_{n})=\mathcal{P}_{n}(\mathbb{R}^{d}) , one has \min_{\alpha\in(\mathbb{R}^{d})^{n}}\min_{\nu\in\mathcal{P}(\alpha_{1},\dots,\alpha_{n})}{\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr)=\\ \min_{\nu\in\mathcal{P}_{n}(\mathbb{R}^{d})}{\mathcal{W}}_{2}\bigl({\mathcal{L}}(Y),\nu\bigr). ∎ 3.4 Competitive Learning Vector Quantization A way to minimize D_{n}(\alpha) and to obtain the corresponding minimizer \alpha is to use Competitive Learning Vector Quantization (CLVQ). In this section, we briefly present the CLVQ algorithm and explain on which condition it is similar to gradient descent. Let \mathcal{D}=\{y_{j}\}_{j=1}^{N} be a dataset. For all \alpha\in\mathbb{R}^{d} and y\in\mathbb{R}^{d} , one chooses I_{\alpha}(y)\in\{1,\dots,n\} such that \lvert y-\alpha_{I_{\alpha}(y)}\rvert=\min_{1\leq i\leq n}\lvert y-\alpha_{i}\rvert To minimize the distortion, CLVQ consists of the recursive scheme where one iteration is written as: \alpha\longleftarrow\alpha-\gamma\Bigl(1_{\{I_{\alpha}(Y)=i\}}(\alpha_{i}-Y)\Bigr)_{1\leq i\leq n} where Y is sampled from \mathcal{D} and \gamma\in(0,1] is the learning rate, the winning \alpha_{i} is getting closer to Y . This is almost a stochastic gradient descent: Proposition 3.3 ( ( Pagès, 2015 ) ) . For all \alpha\in(\mathbb{R}^{d})^{n} such that \mathbb{P}\Bigl(\exists\ i\not=j:\lvert Y-\alpha_{i}\rvert=\lvert Y-\alpha_{j}\rvert\Bigr)=0, (3) D_{n} is differentiable at \alpha and \nabla D_{n}(\alpha)=2\mathbb{E}\Bigl[\Bigl(1_{\{I_{\alpha}(Y)=i\}}(\alpha_{i}-Y)\Bigr)_{1\leq i\leq n}\Bigr] Note that for optimal \alpha^{\star} Assumption 3 is always true, see ( Graf and Luschgy, 2000 ) . While vector quantization provides a robust framework for approximating static distributions, many real-world scenarios involve conditional dependencies. For instance, the distribution of Y may vary with an auxiliary random variable X . To address this, we extend vector quantization to conditional quantization , where the quantizers adapt to X as learnable functions, allowing the approximation of the conditional distribution of Y given X . 4 Conditional Quantization Let X and Y be two random vectors, defined on the same probability space, where X takes its values in an arbitrary space E and Y takes its values in \mathbb{R}^{d} . The objective is to construct an approximation of the conditional law Q(x,dy)=\mathbb{P}(Y\in dy\mid X=x) , which describes the distribution of Y given X=x . More precisely, Q(x,\cdot) , x\in E , is family of distribution on \mathbb{R}^{d} such that for all test function F:\mathbb{R}^{d}\to\mathbb{R} one has, with probability 1 : \mathbb{E}\bigl(F(Y)\mid X\bigr)=\int_{\mathbb{R}^{d}}F(y)Q(X,dy). For a function f=(f_{1},\dots,f_{n}):E\to(\mathbb{R}^{d})^{n} , define: \Delta_{n}(f)=\mathbb{E}\Bigl[\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\Bigr]. The framework of conditional quantization focuses on minimizing \Delta_{n}(f) to approximate Q(X,\cdot) in the Wasserstein sense. This approach generalizes the concept of vector quantization by making the quantizers dependent on X , enabling flexible modeling of conditional distributions. We describe this formalization and its practical applications below. Integrability assumption We assume that there exists f:E\to(\mathbb{R}^{d})^{n} such that \Delta_{n}(f)<\infty . This implies that E\bigl(\lvert Y\rvert^{2}\mid X\bigr)<\infty with probability 1 since \lvert Y\rvert\leq\min_{1\leq i\leq n}\lvert Y-f_{i}(X)\rvert+\max_{1\leq i\leq n}\lvert f_{i}(X\rvert. In other words, with probability 1 : \int_{\mathbb{R}^{d}}\lvert y\rvert^{2}Q(X,dy)<\infty. The distortion functional \Delta_{n}(f) can also be expressed as: \Delta_{n}(f)=\mathbb{E}\Bigl[\bigl|Y-\pi_{f(X)}(Y)\bigr|^{2}\Bigr], where \pi_{f(X)}(Y) is a closest neighbor projection defined by ( 1 ), and the conditional law of \pi_{f(X)}(Y) given X=x can be written as: \widehat{Q}_{f}(x,\cdot)=\sum_{i=1}^{n}Q\bigl(x,\{y\in\mathbb{R}^{d}:\pi_{f(x)}(y)=f_{i}(x)\}\bigr)\,\delta_{f_{i}(x)}(\cdot). Connection to the Wasserstein distance Applying Proposition 3.1 “conditionally to X ”, one obtains: Theorem 4.1 . 1. With probability 1 , one has \displaystyle\mathbb{E}\Bigl[\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\mid X\Bigr] \displaystyle=\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f_{i}(X)\bigr|^{2}Q(X,dy) \displaystyle=\mathcal{W}_{2}\bigl(Q(X,\cdot),\widehat{Q}_{f}(X,\cdot)\bigr)^{2} \displaystyle=\min_{\nu\in\mathcal{P}(f_{1}(X),\dots,f_{n}(X))}\mathcal{W}_{2}\bigl(Q(X,\cdot),\nu\bigr)^{2}, where \mathcal{P}(f_{1}(X),\dots,f_{n}(X)) denotes the set of distributions with support in the set \{f_{1}(X),\dots,f_{n}(X)\} . 2. On has \Delta_{n}(f)=\mathbb{E}\Bigl[\mathcal{W}_{2}\bigl(Q(X,\cdot),\widehat{Q}_{f}(X,\cdot)\bigr)^{2}\Bigr]. Proof. 1. The first equality follows from the definition of Q . Applying Proposition 3.1 to a random vector with distribution Q(x,\cdot) , where x\in E is such that \int\lvert y\rvert^{2}Q(x,dy)<\infty , yields \displaystyle\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f_{i}(x)\bigr|^{2}Q(x,dy) \displaystyle=\mathcal{W}_{2}\bigl(Q(x,\cdot),\widehat{Q}_{f}(x,\cdot)\bigr)^{2} \displaystyle=\min_{\nu\in\mathcal{P}(f_{1}(x),\dots,f_{n}(x))}\mathcal{W}_{2}\bigl(Q(x,\cdot),\nu\bigr)^{2}. Since \int\lvert y\rvert^{2}Q(X,dy)<\infty with probability 1 , one gets the second and the third equalities. 2. It’s a consequence of the first point and the fact that \Delta_{n}(f)=\mathbb{E}\Bigl(\mathbb{E}\Bigl[\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\mid X\Bigr]\Bigr) ∎ Thus, minimizing \Delta_{n}(f) is equivalent to reducing the expected squared Wasserstein distance between the true conditional law Q(X,\cdot) and its quantized approximation \widehat{Q}_{f}(X,\cdot) . Optimal conditional quantizer Here we show there always exists an optimal quantizer for \Delta_{n} and we establish how good is \widehat{Q}_{f^{*}}(X,\cdot) as an approximation of Q(X,\cdot) in Wasserstein distance. Theorem 4.2 . There exists a quantizer f^{*}:E\to(\mathbb{R}^{d})^{n} such that \Delta_{n}(f^{*})=\inf_{f}\Delta_{n}(f). Moreover, for any optimal quantizer f^{*} , with probability 1 , one has \mathcal{W}_{2}\bigl(Q(X,\cdot),\widehat{Q}_{f^{*}}(X,\cdot)\bigr)=\min_{\nu\in\mathcal{P}_{n}(\mathbb{R}^{d})}\mathcal{W}_{2}\bigl(Q(X,\cdot),\nu\bigr), where \mathcal{P}_{n}(\mathbb{R}^{d}) denotes the set of distributions on \mathbb{R}^{d} with support of cardinality at most n . The proof is presented in the Appendix A . Conditional quantization extends the concept of vector quantization to approximate the conditional distribution of Y given X . By minimizing \Delta_{n}(f) , one obtains a quantized approximation \hat{Q}_{f}(X,\cdot) that is close to Q(X,\cdot) in the expected Wasserstein sense. This process involves not only learning the quantizer but also estimating the weights x\mapsto Q\bigl(x,\{y\in\mathbb{R}^{d}:\pi_{f(x)}(y)=f_{i}(x)\}\bigr) associated with it to accurately represent the conditional distribution. In the next subsection, we present how to learn such quantizers, including the estimation of their associated weights. Algorithm 1 One Batch Iteration of CCLVQ 0: 1: \mathcal{B}=\{x_{j},y_{j}\}_{j=1}^{N} : batch of samples 2: n : number of parametric functions (experts)x 3: \{f_{i}(x;\theta_{i})\}_{i=1}^{n} : functions with parameters \theta_{i} 4: \ell : loss function from \mathbb{R}^{d}\times\mathbb{R}^{d}\to\mathbb{R} 5: h(x;\phi) : classifier with parameters \phi 6: \gamma_{\mathrm{exp}},\gamma_{\mathrm{cls}} : learning rates for experts and classifier 7: Initialize \theta_{1},\ldots,\theta_{n} and \phi 8: for j=1 to N do 9: i^{*}(j)\leftarrow\arg\min_{i\in\{1,\dots,n\}}\ell\bigl(y_{j},f_{i}(x_{j};\theta_{i})\bigr) {assign sample to its closest function (expert)} 10: end for 11: for i=1 to n do 12: \displaystyle\theta_{i}\leftarrow\theta_{i}-\gamma_{\mathrm{exp}}\,\nabla_{\theta_{i}}\!\Bigl(\sum_{j:i^{*}(j)=i}\ell(y_{j},f_{i}(x_{j};\theta_{i}))\Bigr) {update only function i on samples assigned to i } 13: end for 14: {train the classifier on the expert assignments} 15: \displaystyle\ell_{\text{classifier}}\leftarrow-\frac{1}{N}\sum_{j=1}^{N}\sum_{i=1}^{n}\mathbbm{1}_{[i^{*}(j)=i]}\log h_{i}(x_{j};\phi) {cross-entropy loss with expert labels} 16: \displaystyle\phi\leftarrow\phi-\gamma_{\mathrm{cls}}\nabla_{\phi}\mathcal{L}_{\text{classifier}} 17: Return \{\theta_{i}\}_{i=1}^{n} , \phi 4.1 Conditional Competitive Learning Vector Quantisation (CCLVQ) We introduce the Conditional Competitive Learning Vector Quantisation (CCLVQ) algorithm to minimize the distortion function \Delta_{n}(f) , where the n functions f=(f_{1},\dots,f_{n}) are parameterized by \theta=(\theta_{1},\dots,\theta_{n}) , respectively. CCLVQ is similar to CLVQ and, thus is closely linked to gradient descent. One iteration associated with one data point (X,Y) is written as \displaystyle\theta\leftarrow\theta-\gamma\Bigl(1_{\{I_{f(X)}(Y)=i\}}\nabla_{\theta_{i}}\bigl|f_{i}(X,\theta_{i})-Y\bigr|^{2}\Bigr)_{1\leq i\leq n} We generalize it to any loss function \ell:\mathbb{R}^{d}\times\mathbb{R}^{d}\to\mathbb{R} : \displaystyle\theta\leftarrow\theta-\gamma\Bigl(1_{\{I_{f(X)}(Y)=i\}}\nabla_{\theta_{i}}\ell(Y,f_{i}(X,\theta_{i}))\Bigr)_{1\leq i\leq n}\ . where, for \alpha\in(\mathbb{R}^{d})^{n} and y in \mathbb{R}^{d} , I_{\alpha}(y)\in\{1,\dots,n\} satisfies \ell(y,\alpha_{I_{\alpha}(y)})=\min_{1\leq i\leq n}\ell(y,\alpha_{i}). The algorithm selectively updates only the parameters of the function that minimizes the distortion for a given sample, iteratively refining the functions to better represent the conditional distribution \mathcal{L}(Y\mid X) . In this context, the functions f_{i} are referred to as experts. Each iteration alternates between two key steps: (1) assigning each sample to its closest expert f_{i} based on the current parameters \theta_{i} , and (2) updating the parameters of the assigned expert using gradient descent. In parallel, a classifier h(x;\phi) is trained to predict the probabilities associated with each expert. These probabilities, or weights, are crucial for approximating the conditional distribution \mathcal{L}(Y\mid X) , as they capture the relative contribution of each expert while also providing a measure of uncertainty, which can be crucial in reconstruction settings such as medical imaging. Introducing new experts We employ the splitting strategy ( Linde et al., 1980 ) to introduce a new expert during training. This approach involves duplicating an existing expert, typically the one with the highest contribution to the overall distortion \Delta_{n}(f) or the largest number of assigned samples. Adding a new expert through splitting is performed during the final training epoch to minimize computational overhead. Figure 1: CCLVQ training loss on the MNIST dataset for an inpainting task, showing the effect of adding new experts using the splitting strategy every 400 epochs. Choice of \mathbf{n} To illustrate the impact on the distortion functional \Delta_{n}(f) of adding a new expert, we experiment with an inpainting task with a random window on MNIST, see Appendix B.1 for more training details. As shown in Figure 1 , the training loss decreases each time a new expert is added. To isolate the impact of adding an expert, we deliberately allowed the model to train for many epochs before introducing a new expert, ensuring convergence before the addition. The choice of the number of experts n is empirical and depends on the task. In this case, we observe a significant improvement in performance for n=3 , beyond which the improvements become less pronounced. A practical approach to reducing computational overhead on large models and datasets is, to begin with, a pretrained model, performing splitting from this pretrained state, and then fine-tuning the resulting experts for a few additional epochs. Figure 2: Visualization of synthetic data showing true data points Y (in grey) and predicted values from every expert (in colors). Each expert captures a specific mode of conditional distribution. 5 Examples of applications 5.1 Multi-value Regression on synthetic data We aim to demonstrate CCLVQ’s applications through multi-value regression, multi-modal reconstruction, and generation experiments. Upon acceptance, the code will be made publicly available. We illustrate Algorithm 1 in a multimodal regression problem. Each expert is a small MLP with one hidden layer of dimension 20 trained with gradient descent following CCLVQ. The data generation process is defined as follows: \displaystyle X\sim\mathcal{N}(0,1),\quad p_{i}(x)=\frac{\exp(a_{i}x+b_{i})}{\sum_{j=1}^{\mathrm{mode}}\exp(a_{j}x+b_{j})}, knowing X , I\sim\mathrm{Cat}\bigl(p_{1}(X),\dots,p_{\mathrm{mode}}(X)\bigr) and \varepsilon\sim\mathcal{N}(0,\sigma^{2}) are independent, \displaystyle Y=\sin\bigl(2IX\bigr)+10I+\varepsilon. Figure 2 shows that each expert learns one mode of the conditional distribution \mathcal{L}(Y\mid X) . In the figure, there are 3 experts and 3 modes. We can also train a classifier h to learn the vector p(X) to have the probability associated with each expert, as depicted in Figure 3 . Experts’ weights better approximate mode probabilities in regions with higher sample density. Figure 3: Weights estimations of experts versus probabilities of mode w.r.t X . Figure 4: Multi-modal inpainting results on MNIST. Each row shows the ground truth Y , masked input X , and reconstructions from different experts, followed by the classifier’s weights as a measure of uncertainty. Figure 5: Multi-modal denoising results on MNIST. Each row shows the ground truth Y , noised input X , and reconstructions from different experts, followed by the classifier’s weights as a measure of uncertainty. 5.2 Multi-modal Reconstruction with Uncertainty Quantification MNIST Dataset In this experiment, we perform inpainting on MNIST digits, where the upper part of each image is masked, as in ( Nehme et al., 2023 ) . The goal is to reconstruct the masked region while considering the inherent ambiguity and multimodality of possible completions, we use an encoder-decoder architecture similar to the one from Pathak et al. (2016) for each expert and a ResNet9 for the classifier h . Figure 4 illustrates the inpainting process on a test set. Each column corresponds to a reconstruction generated by a different expert model f_{i} . The first column X represents the base image, serving as the ground-truth target for reconstruction. The second column Y displays the masked image, which is the input provided to the models. Subsequent columns depict reconstructions produced by the various expert models f_{i} , capturing different plausible completions of the masked region. The weights of each expert learned by the classifier h during training are visualized in the last row. These weights represent the probability distribution over experts for a given reconstruction and provide a measure of uncertainty by indicating the most probable reconstruction. In the same manner, we also illustrate reconstruction for denoising tasks, see Figure 5 . Reconstruction for a unique model trained is provided for the comparison of the same samples with Figure 8 and Figure 9 in the Appendix. CelebA-HQ Dataset Figure 6: Diverse inpainting results on the CelebA-HQ dataset using CCLVQ. Each column shows reconstructions from different expert models after masking the area near the eyes, highlighting variations in eye color, eyebrow shape, and other fine-grained features. Probability for each construction are placed below image. We conducted an inpainting experiment on the CelebA-HQ dataset, masking the area near the eyes on the test set, following the protocol of ( Nehme et al., 2023 ) . The same ResUNet architecture ( Ronneberger et al., 2015 ; Falk et al., 2019 ) was used for this task. The baseline model was trained for 30 epochs with a batch size of 16 . Subsequently, we split the model into four experts and applied CCLVQ for only one additional epoch, significantly reducing computational overhead. This approach led to diverse reconstructions, see Figure 6 and more reconstructions in the Appendix see Figure 10 , demonstrates variations in eye color, eyebrow shape, and other fine-grained features, illustrating the method’s ability to capture multimodal distributions effectively. (a) Dataset (b) n=1 (c) n=2 (d) n=4 (e) n=8 (f) n=16 Figure 7: Samples generated by RealNVP trained on a mixture of 2D Gaussians. As the number of experts increases, the model generates fewer out-of-distribution samples. Each expert is represented by a unique color. Metrics CIFAR-10 CelebA n 1 2 4 2^{*} 1 2 FID (\downarrow) 8.21\pm 0.72 \mathbf{7.34\pm 0.03} 7.74\pm 0.15 8.31\pm 0.14 5.19\pm 0.09 \mathbf{4.75\pm 0.00} Precision (\uparrow) \mathbf{0.85\pm 0.00} \mathbf{0.85\pm 0.00} 0.84\pm 0.00 \mathbf{0.85\pm 0.00} \mathbf{0.78\pm 0.01} \mathbf{0.78\pm 0.00} Recall (\uparrow) 0.69\pm 0.02 \mathbf{0.72\pm 0.01} \mathbf{0.72\pm 0.01} 0.69\pm 0.00 0.62\pm 0.01 \mathbf{0.63\pm 0.00} Entropy (\uparrow) 0 0.981\pm 0.018 0.974\pm 0.010 1 0 0.997\pm 0.001 Table 1: Results of CCLVQ on CIFAR-10 and CelebA datasets. The results show that CCLVQ improves the diversity of the generated samples while maintaining the quality of the samples. We denote by 2^{*} the model with independently trained experts used in a uniform mixture. In bold, the best results. We report the mean and standard deviation over 2 runs. The FID is lower when it is better, while the Precision and Recall are higher when they are better. The normalized entropy is close to 1 when the repartition of the experts is uniform. 5.3 Improving Quality of Normalizing Flows on synthetic data Normalizing Flows (NFs) are a class of generative models that learn a bijective mapping between a simple distribution and a complex target distribution. The networks parameterizing this mapping are designed to ensure that the Jacobian determinant of the transformation remains tractable, allowing for the computation of sample likelihoods. However, due to the invertibility constraint, NFs often struggle to capture multimodal distributions ( Cornish et al., 2020 ; Verine et al., 2023b ) . While these models are effective at producing diverse outputs, they tend to generate out-of-domain samples. To enhance the expressivity of the model, we propose using CCLVQ. We employ the RealNVP architecture ( Dinh et al., 2017 ) and train it on a mixture of 2D Gaussians. The model is trained with n=1,2,4,8, and 16 experts, where only the parameters corresponding to the highest-likelihood samples are updated. Figure 7(a) illustrates the dataset samples. The results, presented in Figures 7(b) to 7(f) , provide insights into how the experts are distributed across the dataspace. 5.4 Improving Diversity Generative Adversarial Networks on CIFAR-10 and CelebA Adapting CCLVQ to GANs: Generative Adversarial Networks are known to suffer from limited diversity in generated samples ( Verine et al., 2023a ) . We propose to use CCLVQ to improve the diversity of GANs by learning a multimodal distribution. GANs are typically composed of two neural networks: a generator G:\mathbb{R}^{k}\rightarrow\mathbb{R}^{d} mapping Gaussian samples to data-like samples and a discriminator D:\mathbb{R}^{d}\rightarrow[0,1] used to estimate a divergence between a target distribution and the distribution generated by G . We use the framework introduced by Brock et al. (2019) where D is trained based on samples from the dataset and from the generator using hinge loss, and G is trained by minimizing \ell(G(x))\coloneqq-D(G(x)) . Here, we propose to replace the generator by a mixture of experts G_{i} . The discriminator is now trained on samples from the dataset and from each generator. However, for a given latent sample X , only the generator G_{i} that minimizes \ell(G_{i}(X)) is trained. Training and Evaluating models We train BigGAN models ( Brock et al., 2019 ) on CIFAR-10 and CelebA datasets. For CIFAR-10, we train a BigGAN model with n=1 , n=2 , and n=4 with two different seeds. As a baseline, we train 2 models independently and use the uniform mixture of the two models as a comparison. For CelebA, we train a BigGAN model with n=1 and n=2 with two different seeds. To evaluate the improvements brought by CCLVQ, we use Frechet Inception Distance (FID) ( Heusel et al., 2017 ) , traditionally used to evaluate proximity to the true distribution. We also use the metrics of Precision and Recall ( Kynkäänniemi et al., 2019 ) to assess independently the quality of the generated samples and their diversity. To evaluate how the experts are used, we compute the entropy of the classifier’s weights normalized by the entropy of the uniform distribution. We report the mean and standard deviation over 2 runs. The results are presented in Table 1 . Generated samples are shown in Figures 11 and 12 in Appendix B.4 . We observe that CCLVQ improves (1) the overall performance of the model (lower FID), and (2) the diversity of the generated samples (higher Recall) with fixed Precision. We can also observe that the normalized entropy is close to 1 indicating that the experts are used uniformly. The experiments also highlight the improvement brought by CCLVQ since the model with independently trained experts performs as well as the model with n=1 . 6 Conclusion and Discussion We introduced Conditional Competitive Learning Vector Quantization (CCLVQ) to approximate conditional distributions in this work. Our approach extends traditional vector quantization methods by incorporating learnable functions that adapt to the input distribution, enabling effective uncertainty quantification and diverse and precise sample generation. We demonstrated the theoretical grounding of our method and its practical applications across multiple domains, including image inpainting, denoising, and generative modeling. Experimental results validate the efficacy of CCLVQ in capturing multimodal structures while maintaining computational efficiency. With a finite number of examples (X_{i},Y_{i}) , 1\leq i\leq N , the algorithm, at best, provides an approximation of {\mathcal{L}}(\tilde{Y}\mid\tilde{X}) , where (\tilde{X},\tilde{Y}) follows the empirical distribution. If N is sufficiently large, this approximation can be accurate; however, the size of the neural networks also plays a significant role in this context. A detailed study of this problem is beyond the scope of this paper. Impact Statement This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none of which we feel must be specifically highlighted here. Appendix A Proof Theorem . There exists a quantizer f^{*}:E\to(\mathbb{R}^{d})^{n} such that \Delta_{n}(f^{*})=\inf_{f}\Delta_{n}(f). Moreover, for any optimal quantizer f^{*} , with probability 1 , one has \mathcal{W}_{2}\bigl(Q(X,\cdot),\widehat{Q}_{f^{*}}(X,\cdot)\bigr)=\min_{\nu\in\mathcal{P}_{n}(\mathbb{R}^{d})}\mathcal{W}_{2}\bigl(Q(X,\cdot),\nu\bigr), where \mathcal{P}_{n}(\mathbb{R}^{d}) denotes the set of distributions on \mathbb{R}^{d} with support of cardinality at most n . Proof. We construct a quantizer f^{*}:E\to(\mathbb{R}^{d})^{n} as follows: for each x\in E such that \int_{\mathbb{R}^{d}}\lvert y\rvert^{2}Q(x,dy)<\infty choose f^{*}(x)=(f^{*}_{1}(x),\dots,f^{*}_{n}(x))\in(\mathbb{R}^{d})^{n} satisfying \displaystyle\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f_{i}^{*}(x)\bigr|^{2}Q(x,dy) \displaystyle=\min_{\alpha\in(\mathbb{R}^{d})^{n}}\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-\alpha_{i}\bigr|^{2}Q(x,dy). Such a f^{*}(x) exists since we know that the distribution Q(x,\cdot) admits at least one optimal quantizer. As \int_{\mathbb{R}^{d}}\lvert y\rvert^{2}Q(X,dy)<\infty with probability 1 , f^{*}(X) is well defined with probability 1 . Let us prove that \Delta_{n}(f^{*})\leq\Delta_{n}(f) for all f . On the one hand, for any f , one has \displaystyle\Delta_{n}(f^{*}) \displaystyle=\mathbb{E}\Bigl[\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\Bigr] \displaystyle=\mathbb{E}\Bigl[\mathbb{E}\Bigl(\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\mid X\Bigr)\Bigr] On the other hand, for any f , with probability 1 , one has \displaystyle\mathbb{E}\Bigl(\min_{1\leq i\leq n}\bigl|Y-f^{*}_{i}(X)\bigr|^{2}\mid X\Bigr) \displaystyle=\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f^{*}_{i}(X)\bigr|^{2}Q(X,dy) \displaystyle\leq\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f_{i}(X)\bigr|^{2}Q(X,dy) \displaystyle=\mathbb{E}\Bigl(\min_{1\leq i\leq n}\bigl|Y-f_{i}(X)\bigr|^{2}\mid X\Bigr) By taking the expectation of both side, one obtains that \Delta_{n}(f^{*})\leq\Delta_{n}(f) . Moreover if f is optimal, that is \Delta_{n}(f)=\Delta_{n}(f^{*}) , one has necessarily, with probability 1 : \displaystyle\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f_{i}(X)\bigr|^{2}Q(X,dy) \displaystyle=\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-f^{*}_{i}(X)\bigr|^{2}Q(X,dy) \displaystyle=\min_{\alpha\in(\mathbb{R}^{d})^{n}}\int_{\mathbb{R}^{d}}\min_{1\leq i\leq n}\bigl|y-\alpha_{i}\bigr|^{2}Q(X,dy). In other words, with probability 1 , f(X) is an optimal quantizer for Q(X,\cdot) and Proposition 3.2 yields: \mathcal{W}_{2}\bigl(Q(X,\cdot),\widehat{Q}_{f}(X,\cdot)\bigr)=\min_{\nu\in\mathcal{P}_{n}(\mathbb{R}^{d})}\mathcal{W}_{2}\bigl(Q(X,\cdot),\nu\bigr). ∎ Appendix B Experimental details B.1 Inpainter Architecture and Training Details on MNIST On the Experiment 8 , the Inpainter model employs an encoder-bottleneck-decoder [ Pathak et al., 2016 ] structure for image inpainting. The encoder compresses input images using two convolutional layers with Batch Normalization and ReLU. The bottleneck captures abstract representations with two convolutional layers. The decoder reconstructs the image with transposed convolutional layers and outputs through a Sigmoid-activated layer. Training is conducted on MNIST with upper-image masking, using a batch size of 128 for 200 epochs. The optimizer is Adam with a 0.001 learning rate, and the loss function is Mean Squared Error (MSE). Ten expert models are trained to handle different reconstruction modes, with periodic addition of new experts. A noise loss regularization term is applied, and the denoising mode ensures robustness to noisy inputs. B.2 Comparison to one single model for reconstruction Figure 8: Inpainting results on MNIST for a unique model case. Each row shows the ground truth Y , masked input X , and reconstructions from the model. Figure 9: Denoising results on MNIST for a unique model case. Each row shows the ground truth Y , noised input X , and reconstructions from the model. B.3 Training details on CelebA-HQ The training process for the CelebA-HQ dataset began with a baseline model trained for 30 epochs. Starting from this baseline, 9 additional networks were duplicated, resulting in 10 experts. These experts were trained for one additional epoch using the CCLVQ training algorithm. The initial assignment of samples to experts was guided by a noisy loss function (small Gaussian noise added to the loss), designed to encourage each expert to specialize in a distinct subset of the data and to avoid a winner-takes-all effect. Batch accumulation stabilized training by effectively increasing the batch size by a factor of 8 (from 16 to 128). This ensured smoother gradient updates and enhanced convergence during the training process. The training was performed on 1 GPU A100. Figure 10: More inpainting results on the CelebA-HQ dataset using CCLVQ. B.4 Training details on BigGAN The training process for BigGAN models on CIFAR-10 and CelebA datasets is as follows. We use the PyTorch implementation given in https://github.com/ajbrock/BigGAN-PyTorch . We use the same set of hyperparameters given in the repository. For multiple experts, we stack the number of gradient updates until all experts receive the same number of updates as the baseline model. For CIFAR-10, the model has been trained on 2 GPUs V100 16Go for 500 epochs with a batch size of 50. The learning rate is set to 0.0002 and the Adam optimizer is used. For CelebA, the model has been trained on 4 GPUs V100 32Go for 100 epochs with a batch size of 128. The learning rate is set to 0.00002 and the Adam optimizer is used. We evaluate the models using the FID, Precision, and Recall metrics with 50k samples and k=3 . We report some visualization of the generated data in Figures 11 and 12 . (a) n=1 (b) n=2 , Model 1 (c) n=2 , Model 2 (d) n=2 , Mixture Figure 11: Generated CIFAR-10 samples from BigGAN models with n=1 and n=2 experts. (a) n=1 (b) n=2 , Model 1 (c) n=2 , Model 2 (d) n=2 , Mixture Figure 12: Generated CelebA samples from BigGAN models with n=1 and n=2 experts.