Published on

From Spread MLE to Implicit MLE

Authors
Mingtian Zhang

1. Implicit Generative Models and IMLE

Implicit generative models are easy to sample from but often do not have a tractable likelihood. Let

Z∼p(z),Y=Gθ(Z),Z\sim p(z), \qquad Y=G_\theta(Z),

and let qθq_\theta denote the resulting distribution of YY. We can generate samples from qθq_\theta, but evaluating qθ(x)q_\theta(x) may be impossible. The problem is even more severe when qθq_\theta is supported on a low-dimensional manifold, because an ordinary density may not exist at all.

Implicit Maximum Likelihood Estimation (IMLE) trains such a generator without ever requiring access to its density. Given a data distribution pdatap_{\mathrm{data}}, the population IMLE objective can be written as

LIMLE(θ)=EX∼pdataEY1:m∼qθm[min⁡1≤j≤m∥X−Yj∥2].\mathcal L_{\mathrm{IMLE}}(\theta) = \mathbb E_{X\sim p_{\mathrm{data}}} \mathbb E_{Y_{1:m}\sim q_\theta^m} \left[ \min_{1\le j\le m} \|X-Y_j\|^2 \right].

For an empirical dataset x1,…,xnx_1,\ldots,x_n, this becomes

L^IMLE(θ)=EY1:m∼qθm[1n∑i=1nmin⁡1≤j≤m∥xi−Yj∥2].\widehat{\mathcal L}_{\mathrm{IMLE}}(\theta) = \mathbb E_{Y_{1:m}\sim q_\theta^m} \left[ \frac1n \sum_{i=1}^n \min_{1\le j\le m} \|x_i-Y_j\|^2 \right].

In practice, IMLE repeatedly performs three steps:

  1. Sample a pool of latent codes z1,…,zmz_1,\ldots,z_m.
  2. Generate candidates Yj=Gθ(zj)Y_j=G_\theta(z_j).
  3. For each data point, find its nearest generated candidate and update the generator to reduce the matched distance.

The matching direction is important: every data point selects a generated sample. This encourages the generator to cover all observed modes rather than only improving samples in regions it already generates well.

The expectation over Y1:mY_{1:m} averages over the random candidate pools produced by the model. The empirical average over the data can equivalently be viewed as an expectation under the empirical data distribution.

This objective does not immediately resemble a likelihood-based objective. The following sections show how it can be derived from a finite-sample approximation to spread maximum likelihood.

2. From an Ill-Defined KL to the Spread KL Divergence

Consider a data distribution pdatap_{\mathrm{data}} and an implicit model distribution qθq_\theta. A natural objective is the forward KL divergence, which, whenever both distributions admit densities with respect to the same base measure, can be written as

KL⁡(pdata∥qθ)=EX∼pdata[log⁡pdata(X)−log⁡qθ(X)].\operatorname{KL} \left( p_{\mathrm{data}} \|q_\theta \right) = \mathbb E_{X\sim p_{\mathrm{data}}} \left[ \log p_{\mathrm{data}}(X) - \log q_\theta(X) \right].

Since the first term does not depend on θ\theta, minimizing the forward KL is equivalent to maximum likelihood:

arg⁡min⁡θKL⁡(pdata∥qθ)=arg⁡max⁡θEX∼pdata[log⁡qθ(X)].\arg\min_\theta \operatorname{KL} \left( p_{\mathrm{data}} \|q_\theta \right) = \arg\max_\theta \mathbb E_{X\sim p_{\mathrm{data}}} \left[ \log q_\theta(X) \right].

That premise fails for the implicit generator above. Mapping a low-dimensional latent into a higher-dimensional observation space leaves qθq_\theta supported on a lower-dimensional manifold, with no ordinary density with respect to the ambient Lebesgue measure. Worse, even when pdatap_{\mathrm{data}} and qθq_\theta both concentrate on low-dimensional manifolds, their supports may fail to overlap exactly, in which case KL⁡(pdata∥qθ)\operatorname{KL}(p_{\mathrm{data}}\|q_\theta) is infinite or not meaningfully defined through ordinary density ratios.

Spreading the Distributions

Spread divergence addresses this by applying the same smoothing kernel to both distributions. Using Gaussian spreading,

X~=X+σϵ,Y~=Y+σϵ′,ϵ,ϵ′∼N(0,I),\widetilde X = X+\sigma\epsilon, \qquad \widetilde Y = Y+\sigma\epsilon', \qquad \epsilon,\epsilon'\sim\mathcal N(0,I),

the corresponding spread distributions are the convolutions

pσ=pdata∗ϕσ,qθ,σ=qθ∗ϕσ,ϕσ(u)=N(u;0,σ2I).p_\sigma = p_{\mathrm{data}}*\phi_\sigma, \qquad q_{\theta,\sigma} = q_\theta*\phi_\sigma, \qquad \phi_\sigma(u) = \mathcal N(u;0,\sigma^2I).

Gaussian convolution turns the original, possibly singular distributions into smooth distributions with densities over the full observation space. The spread KL divergence

KL⁡(pσ∥qθ,σ)\operatorname{KL} \left( p_\sigma \|q_{\theta,\sigma} \right)

is therefore well defined, whatever the supports of pdatap_{\mathrm{data}} and qθq_\theta happen to be.

Why Spreading Loses Nothing

Well-definedness alone would not be enough. Smoothing could in principle blur away exactly the differences we are trying to detect, leaving an objective that is finite but no longer informative about the original distributions. This does not happen for Gaussian spreading: the spread KL is a genuine divergence on the original distributions,

KL⁡(pσ∥qθ,σ)=0⟺pdata=qθ.\boxed{ \operatorname{KL} \left( p_\sigma \|q_{\theta,\sigma} \right) = 0 \quad\Longleftrightarrow\quad p_{\mathrm{data}} = q_\theta . }

This holds for every fixed σ>0\sigma>0, and follows from the fact that Gaussian convolution is injective, so that pσ=qθ,σp_\sigma=q_{\theta,\sigma} already forces pdata=qθp_{\mathrm{data}}=q_\theta. See the spread divergence paper for the proof and for the general conditions a noise distribution must satisfy for its spread divergence to be a valid divergence.

So nothing is lost by spreading: driving the spread KL to zero matches the two distributions we actually care about, even though KL⁡(pdata∥qθ)\operatorname{KL}(p_{\mathrm{data}}\|q_\theta) may itself be ill-defined. What remains is to turn this divergence into something we can optimize.

3. Spread Maximum Likelihood

Expanding the spread KL exactly as before,

KL⁡(pσ∥qθ,σ)=EX~∼pσ[log⁡pσ(X~)−log⁡qθ,σ(X~)],\operatorname{KL} \left( p_\sigma \|q_{\theta,\sigma} \right) = \mathbb E_{\widetilde X\sim p_\sigma} \left[ \log p_\sigma(\widetilde X) - \log q_{\theta,\sigma}(\widetilde X) \right],

the first term again does not depend on θ\theta. Minimizing the spread KL is therefore maximum likelihood under the spread model, which gives the Spread Maximum Likelihood objective

Lspread(θ)=EX~∼pσ[log⁡qθ,σ(X~)].\boxed{ \mathcal L_{\mathrm{spread}}(\theta) = \mathbb E_{\widetilde X\sim p_\sigma} \left[ \log q_{\theta,\sigma}(\widetilde X) \right]. }

Because the two objectives differ only by a θ\theta-independent constant, the identifiability of the spread KL carries over directly. Assuming the data distribution is realizable,

arg⁡max⁡θLspread(θ)={θ:qθ=pdata}.\arg\max_\theta \mathcal L_{\mathrm{spread}}(\theta) = \left\{ \theta: q_\theta = p_{\mathrm{data}} \right\} .

Spread MLE is thus not a compromise objective that merely happens to be computable. Its optimum recovers the unspread data distribution, so it estimates the same thing ordinary MLE would have estimated had the latter been well defined.

For an implicit model, the spread density is a Gaussian mixture over model samples,

qθ,σ(x)=EY∼qθ[N(x;Y,σ2I)],q_{\theta,\sigma}(x) = \mathbb E_{Y\sim q_\theta} \left[ \mathcal N(x;Y,\sigma^2I) \right],

which is a smooth density even when the original model is implicit or singular. Substituting it in,

Lspread(θ)=EX~[log⁡EY∼qθexp⁡(−∥X~−Y∥22σ2)]+C.\mathcal L_{\mathrm{spread}}(\theta) = \mathbb E_{\widetilde X} \left[ \log \mathbb E_{Y\sim q_\theta} \exp\left( -\frac{\|\widetilde X-Y\|^2}{2\sigma^2} \right) \right] +C.

This is a valid likelihood objective, but the inner expectation is generally intractable.

4. A Finite-Sample Approximation

Draw mm samples from the implicit model:

Y1,…,Ym∼qθ.Y_1,\ldots,Y_m\sim q_\theta.

The spread density can be approximated by a finite Gaussian mixture:

q^θ,σ,m(x)=1m∑j=1mN(x;Yj,σ2I).\widehat q_{\theta,\sigma,m}(x) = \frac1m \sum_{j=1}^m \mathcal N(x;Y_j,\sigma^2I).

This gives empirical spread MLE, the objective Lm,σ\mathcal L_{m,\sigma} at finite mm,

Lm,σ(θ)=EX~,Y1:m[log⁡1m∑j=1mexp⁡(−∥X~−Yj∥22σ2)]+C.\mathcal L_{m,\sigma}(\theta) = \mathbb E_{\widetilde X,Y_{1:m}} \left[ \log \frac1m \sum_{j=1}^m \exp\left( -\frac{\|\widetilde X-Y_j\|^2}{2\sigma^2} \right) \right] +C.

Because the finite mixture is an unbiased estimator of the spread density, Jensen's inequality gives

Lm,σ(θ)≤Lspread(θ).\mathcal L_{m,\sigma}(\theta) \le \mathcal L_{\mathrm{spread}}(\theta).

This is the same general construction used in multi-sample likelihood bounds such as the importance weighted autoencoder: a finite Monte Carlo average is placed inside the logarithm, and the expectation of the resulting log gives a lower bound on the exact log marginal likelihood.

As m→∞m\to\infty, the finite mixture approaches the exact spread density under suitable conditions.

5. The Small-Noise Limit

Consider the core log-sum-exp term:

−2σ2log⁡∑j=1mexp⁡(−∥X~−Yj∥22σ2).-2\sigma^2 \log \sum_{j=1}^m \exp\left( -\frac{\|\widetilde X-Y_j\|^2}{2\sigma^2} \right).

Fix XX, ϵ\epsilon and Y1:mY_{1:m} for a moment. As σ→0\sigma\to0, the largest exponential term dominates, so that pointwise

−2σ2log⁡∑j=1mexp⁡(−∥X~−Yj∥22σ2)⟶min⁡j∥X−Yj∥2.-2\sigma^2 \log \sum_{j=1}^m \exp\left( -\frac{\|\widetilde X-Y_j\|^2}{2\sigma^2} \right) \longrightarrow \min_j \|X-Y_j\|^2.

The same limit performs two operations at once:

  1. The data noise disappears because
X~=X+σϵ→X.\widetilde X=X+\sigma\epsilon\to X.
  1. The soft Gaussian responsibilities become a hard nearest-neighbour assignment.

Both the 1m\frac1m inside the logarithm and the additive constant CC are killed by the σ2\sigma^2 factor, so rescaling Lm,σ\mathcal L_{m,\sigma} by −2σ2-2\sigma^2 yields

−2σ2 Lm,σ(θ)  ⟶  EX∼pdataEY1:m∼qθm[min⁡j∥X−Yj∥2]=LIMLE(θ),-2\sigma^2\,\mathcal L_{m,\sigma}(\theta) \;\longrightarrow\; \mathbb E_{X\sim p_{\mathrm{data}}} \mathbb E_{Y_{1:m}\sim q_\theta^m} \left[ \min_j \|X-Y_j\|^2 \right] = \mathcal L_{\mathrm{IMLE}}(\theta),

which is exactly the population IMLE objective of Section 1. This last step exchanges the limit with the expectation, which is not automatic: assuming pdatap_{\mathrm{data}} and qθq_\theta have finite second moments, and under suitable uniform-integrability conditions, the limit may be passed through the expectation. Bounded GθG_\theta, or a compact parameter set with uniformly bounded second moments, is enough in practice.

Replacing pdatap_{\mathrm{data}} by the empirical distribution of x1,…,xnx_1,\ldots,x_n gives L^IMLE(θ)\widehat{\mathcal L}_{\mathrm{IMLE}}(\theta),

EY1:m∼qθm[1n∑i=1nmin⁡j∥xi−Yj∥2].\mathbb E_{Y_{1:m}\sim q_\theta^m} \left[ \frac1n \sum_{i=1}^n \min_j \|x_i-Y_j\|^2 \right].

Note that the rescaling factor −2σ2-2\sigma^2 is negative, which is what reconciles the two directions of optimisation. Therefore, at the objective-function level, IMLE is the small-noise limit of the rescaled finite-sample spread likelihood. Each training example is matched to its nearest generated sample, and the generator is trained to reduce those distances.

6. The Connection

The relationship can be summarized as

Spread MLE→finite Monte Carlo Gaussian mixture→small-noise hard assignment→IMLE.\boxed{ \text{Spread MLE} \rightarrow \text{finite Monte Carlo Gaussian mixture} \rightarrow \text{small-noise hard assignment} \rightarrow \text{IMLE}. }

More explicitly, working throughout with the −2σ2-2\sigma^2 rescaling of the previous section,

−2σ2log⁡EY∼qθexp⁡(−∥X+σϵ−Y∥22σ2)≈−2σ2log⁡1m∑j=1mexp⁡(−∥X+σϵ−Yj∥22σ2)→σ→0min⁡j∥X−Yj∥2.\begin{aligned} & -2\sigma^2 \log \mathbb E_{Y\sim q_\theta} \exp\left( -\frac{\|X+\sigma\epsilon-Y\|^2}{2\sigma^2} \right) \\ &\quad\approx -2\sigma^2 \log \frac1m \sum_{j=1}^m \exp\left( -\frac{\|X+\sigma\epsilon-Y_j\|^2}{2\sigma^2} \right) \\ &\quad\xrightarrow[\sigma\to0]{} \min_j \|X-Y_j\|^2 . \end{aligned}

The first step is a finite Monte Carlo approximation. The second is an exact pointwise limit; passing the limit through the expectation requires standard integrability conditions. The 1m\frac1m inside the logarithm contributes 2σ2log⁡m2\sigma^2\log m, which vanishes as σ→0\sigma\to0 and so leaves no trace in the limit.

7. Empirical Spread MLE

Read the other way round, the derivation says that empirical spread MLE (SMLE) contains IMLE as its σ→0\sigma\to0 special case, and so is a strict generalization of it: the same nearest-sample machinery, with σ\sigma left as a free knob rather than sent to zero. Is that knob worth having?

Pleasingly, the whole objective is four lines, and σ=0\sigma=0 selects the limit:

def SMLE_loss(X, Y, sigma):                     # sqdist(A, B)[i, j] = ||a_i - b_j||^2
    if sigma == 0:                              # the IMLE limit
        return sqdist(X, Y).min(dim=1).values.mean()
    Xt = X + sigma * torch.randn_like(X)        # spread the data too
    return -torch.logsumexp(-sqdist(Xt, Y) / (2 * sigma**2), dim=1).mean()

Everything θ\theta-independent has been dropped — the mixture's 1m\frac1m, the Gaussian normaliser, and the 2σ22\sigma^2 scale — since at fixed σ\sigma none of them move the minimiser. IMLE is then not a separate method to implement; it is the branch you get by setting the knob to zero.

What the data noise actually does

The ϵ\epsilon in X~=x+σϵ\widetilde X=x+\sigma\epsilon is a second Monte Carlo source on top of the pool Y1:mY_{1:m}, and it is worth asking what it contributes, because the ϵ\epsilon integral can be done in closed form. Expand the exponent,

−∥x+σϵ−Yj∥22σ2=−∥x−Yj∥22σ2−ϵ⊤(x−Yj)σ−∥ϵ∥22,-\frac{\|x+\sigma\epsilon-Y_j\|^2}{2\sigma^2} = -\frac{\|x-Y_j\|^2}{2\sigma^2} -\frac{\epsilon^\top\left(x-Y_j\right)}{\sigma} -\frac{\|\epsilon\|^2}{2},

and integrate against N(ϵ;0,I)\mathcal N(\epsilon;0,I). Completing the square in ϵ\epsilon leaves a Gaussian integral, and

Eϵ[exp⁡(−∥x+σϵ−Yj∥22σ2)]=2−d/2exp⁡(−∥x−Yj∥24σ2).\boxed{ \mathbb E_{\epsilon} \left[ \exp\left( -\frac{\|x+\sigma\epsilon-Y_j\|^2}{2\sigma^2} \right) \right] = 2^{-d/2} \exp\left( -\frac{\|x-Y_j\|^2}{4\sigma^2} \right) . }

Note the 4σ24\sigma^2: spreading the data has turned the width-σ\sigma kernel into a width-2 σ\sqrt2\,\sigma one. That is exactly what it should do — the kernel is being evaluated at a point that itself carries width-σ\sigma noise, and two Gaussians of width σ\sigma convolve to one of width 2 σ\sqrt2\,\sigma. The prefactor 2−d/22^{-d/2} is θ\theta-independent and joins the other discarded constants.

The catch is that the logarithm sits outside the ϵ\epsilon expectation, so this identity does not simply substitute in. Applying it exchanges Eϵ\mathbb E_\epsilon with log⁡\log, which by Jensen gives a bound rather than an equality:

Lm,σ(θ)  ≤  EX,Y1:m[log⁡1m∑j=1mexp⁡(−∥X−Yj∥24σ2)]+const.\mathcal L_{m,\sigma}(\theta) \;\le\; \mathbb E_{X,Y_{1:m}} \left[ \log \frac1m \sum_{j=1}^m \exp\left( -\frac{\|X-Y_j\|^2}{4\sigma^2} \right) \right] +\text{const} .

The right-hand side is the same objective evaluated on clean data at noise level 2 σ\sqrt2\,\sigma. So the choice of whether to sample the data noise is not a separate design axis at all: dropping it keeps you inside the same one-parameter family and merely moves you along the σ\sigma axis by a factor of 2\sqrt2, up to a Jensen gap that closes as σ→0\sigma\to0. The σ\sigma sweep below is robust to that choice for the same reason.

What sampling ϵ\epsilon does cost is variance. Under the −2σ2-2\sigma^2 rescaling the noise enters the exponent as 2σ ϵ⊤(x−Yj)+σ2∥ϵ∥2=O(σ)2\sigma\,\epsilon^\top(x-Y_j)+\sigma^2\|\epsilon\|^2=O(\sigma), so the cost shrinks with σ\sigma rather than growing: measuring the gradient variance over 300 replicates on the setup below, evaluating at the clean xx reduces it by 5.8×5.8\times at σ=1.0\sigma=1.0, 1.5×1.5\times at σ=0.4\sigma=0.4, and only 1.1×1.1\times by σ=0.05\sigma=0.05, where resampling the pool Y1:mY_{1:m} dominates instead.

A 2D check: the data are eight Gaussians on a ring, the generator is a small MLP mapping z∈R2z\in\mathbb R^2 to R2\mathbb R^2, and a fresh pool of m=128m=128 candidates is drawn at every step so the objective matches the EY1:m\mathbb E_{Y_{1:m}} above. Between runs the only thing that changes is σ\sigma. Full code here.

samples for decreasing sigma, converging to IMLE

At σ=0.05\sigma=0.05 the samples are visually indistinguishable from IMLE, down to the filaments the generator strands between modes. The limit is not a formality — the two objectives really do train to the same solution.

The interesting part is in between. Look again at the sweep above: at σ=0.4\sigma=0.4 the samples sit tightly on the eight modes, and as σ\sigma shrinks they progressively smear out into the gaps, with IMLE the loosest of all. The hard limit is not the best member of the family — keeping the log-sum-exp is what buys the cleaner samples.

The mechanism is visible in the gradient. Both objectives pull candidates toward data,

∂∂Yj=2n∑i=1nwij(Yj−xi),\frac{\partial}{\partial Y_j} = \frac2n \sum_{i=1}^n w_{ij} \left( Y_j-x_i \right),

and differ only in wijw_{ij}: empirical spread MLE at σ>0\sigma>0 uses the mixture responsibility softmax⁡j(−∥xi−Yj∥2/2σ2)\operatorname{softmax}_j\left(-\|x_i-Y_j\|^2/2\sigma^2\right), IMLE a one-hot indicator on the nearest candidate. Under one-hot weights a candidate receives no signal at all unless it wins some match, so a sample stranded between modes can stay there; under soft weights it still feels a pull from every nearby data point.

At the other extreme σ=1.0\sigma=1.0 washes the modes out completely. That is not a failure of the spread divergence — the identifiability of Section 2 holds at every fixed σ>0\sigma>0 — but a finite-mm, finite-budget optimisation effect: the objective becomes so flat that the gradient cannot resolve structure at the scale of the modes. Useful σ\sigma is a middle band, and IMLE sits at one end of it.

8. What Spread MLE Buys

Three things come out of the derivation.

IMLE stops looking arbitrary. Its design choices are not choices at all; each one is forced by the construction. Generated samples act as mixture centers because the spread model is a mixture centred on model samples. Squared Euclidean distance appears because the spreading kernel is Gaussian — a different kernel would give a different cost. Each data point takes its nearest sample because that is what the log-sum-exp degenerates into. The expectation over freshly drawn pools Y1:mY_{1:m} is there because the mixture is a Monte Carlo estimate, not a fixed set. And the mode-covering behaviour follows from the direction of the match, data to samples, which is the direction a likelihood of the data under the model demands.

The estimator gets a target. A nearest-neighbour distance on its own is a heuristic: minimising it does not obviously estimate anything. Spread MLE is a likelihood, and by Section 2 its optimum is qθ=pdataq_\theta=p_{\mathrm{data}} at every fixed σ>0\sigma>0 — the unspread data distribution, the same thing ordinary MLE would target if it were well defined. That is what makes this a principled route to fitting a singular implicit model rather than a convenient distance.

σ\sigma becomes a knob rather than a constant. IMLE is the σ→0\sigma\to0 corner of a one-parameter family, and on the toy problem the corner is not the best place to stand: σ=0.4\sigma=0.4 put nearly all samples on the modes where IMLE strands many of them in between. Two things are given up in the limit. The finite-sample objective is only a lower bound on spread likelihood, with a Jensen gap at fixed mm,

EY1:m[log⁡q^θ,σ,m(x)]≤log⁡qθ,σ(x),\mathbb E_{Y_{1:m}} \left[ \log \widehat q_{\theta,\sigma,m}(x) \right] \le \log q_{\theta,\sigma}(x),

and the hard assignment throws away every soft responsibility but one. Neither loss is forced on you — they are the price of the corner, not of the framework.

So the summary cuts both ways:

IMLE is the zero-noise hard-assignment limit of a finite-sample approximation to spread maximum likelihood — and spread MLE is the likelihood that limit came from, identifiable at every σ>0\sigma>0, with the interior of the family worth exploring.

References

Citation

@misc{zhang2026spreadmle,
  title  = {From Spread MLE to Implicit MLE},
  author = {Zhang, Mingtian},
  year   = {2026},
  month  = {August},
  url    = {https://mingtian.ai/blog/SpreadMLEtoIMLE},
  note   = {Blog post}
}