cd /news/machine-learning/can-the-shape-of-data-predict-where-… · home › topics › machine-learning › article
[ARTICLE · art-179922] src=pub.towardsai.net ↗ pub= topic=machine-learning verified=true sentiment=· neutral

Can the Shape of Data Predict Where a Classifier’s Decision Boundary Is?

A researcher's pilot study found that a second-order "energy contrast" predictor built from generative models trained separately on source and target classes landed closer to a classifier's true decision boundary than a first-order predictor in 89, 89 and 97 of 120 test points across three victim classifiers, but the reduction in victim queries was tiny and statistically indistinguishable from zero. The approach uses the gradient and signed Hessian of a calibrated energy contrast to predict where it crosses zero along candidate directions, reserving hard-label queries only to verify and refine those predictions. The author outlines the math, the pilot results and a pre-registered test plan for whether class-conditional generative models can forecast decision-based adversarial attack boundaries before an attack starts.

recommendation

Treat boundary-prediction gains as unproven until query savings clear zero: the second-order predictor won on 89-97 of 120 points but saved no measurable victim queries.

more in playbook: Evals and testing for LLM apps
by read31 min views7 publishedDec 2, 2026

TL;DR. Decision-based adversarial attacks only see a classifier’s predicted labels, so they burn hundreds or thousands of queries just to find the decision boundary. I’m asking a different question: can generative models trained separately on the source and target classes predict where that boundary is before the attack starts? I build a calibrated “energy contrast” between the two classes, use its gradient (first-order) and its signed Hessian (second-order) to predict where it crosses zero along a set of candidate directions, and then use hard-label queries only to verify and refine those predictions. In early synthetic experiments the second-order predictor lands closer to the true crossing than the first-order one in 89, 89 and 97 of 120 test points across three victim classifiers, but the savings in victim queries are tiny and statistically indistinguishable from zero. This post walks through the idea, the math, the pilot results, the pre-registered test plan and, honestly, what could go wrong.

Consider an image classifier trained to distinguish between dogs and cats.

For an input image x ∈ ℝᴰ, the classifier produces a collection of internal scores:

**z(x) = [z₁(x), z₂(x), …, z꜀(x)]**

Its prediction is determined by the class with the highest score.

For a binary classification problem involving source class s and target class t, we can define a discriminative margin:

**m(x) = zₜ(x) − zₛ(x)**

The corresponding decision boundary is characterized by:

Bꜰ = {x ∈ ℝᴰ : m(x) = 0} At a regular point, this equation describes a local interface separating two decision regions. In a multiclass setting, the corresponding scores must also dominate those of the remaining classes.

Now consider the same problem from a generative perspective.

Instead of directly learning a classification function, suppose we estimate the probability densities associated with the two classes:

These distributions describe how the respective classes are represented within the input space.

Given class priors πₛ and πₜ, the Bayes decision interface between the two classes satisfies:

**πₛpₛ(x) = πₜpₜ(x)**

Equivalently,

**log[πₜpₜ(x) / πₛpₛ(x)] = 0**

This gives us two different geometric objects: a boundary determined by a trained classifier and an ambiguity surface determined by class distributions.

If a classifier were an exact Bayes classifier for those distributions, these interfaces would agree under the appropriate regularity conditions. In practice, however, classifiers are trained using finite data, particular architectures, optimization objectives, regularization, and learned representations. There is therefore no guarantee that their decision boundaries coincide with the generative ambiguity surface.

The relationship between these two surfaces is what interests me.

Decision-based adversarial attacks operate under a particularly restrictive assumption: the classifier returns only its predicted class.

Given an input x, we observe f(x), but not the internal scores, probabilities, or gradients that determine that prediction.

Most decision-based attacks learn about the boundary by talking to the victim:

• Boundary Attack introduced label-based distortion reduction.

• HopSkipJumpAttack (HSJA) estimates directions near the boundary from decisions; QEBA adds representative subspaces to boundary-normal estimation.

• GeoDA studies the local geometry of the observed boundary; SurFree and Triangle Attack use structured geometric searches.

• CGBA (and its targeted variant, CGBA-H) account for curved search paths using victim feedback; ADBA reduces queries by approximating boundary distances when comparing directions.

Another family borrows a prior from a separate model: EigenBA (singular vectors of a representation Jacobian, though in its original form it queries target probabilities), NonLinear BA (a learned nonlinear projection for gradient estimation), DTA (a transferable transformation model), latent generative attacks, and Moraffah and Liu’s generative surrogate learned near a target model’s boundary. Diffusion-guided decision-only editing is another neighbor.

So using a generative prior is not, by itself, new. The gap I’m targeting is narrower: a prediction of boundary location, made before any victim interaction, from class-density derivatives learned independently of the victim. And I define “location” operationally: compute roots of the generative contrast along a fixed menu of unit directions and take the feasible root with the shortest Euclidean displacement. That approximates a nearby point on the learned class-ambiguity surface. It is explicitly not an estimate of the globally nearest point on the victim’s boundary.

Rather than beginning with an entirely unknown boundary, I wanted to investigate whether independently learned class distributions could provide a useful geometric prior.

The distinction is important.

A generative model would not be trained to imitate the classifier. It would instead learn the source and target distributions independently, and the information contained in those distributions would be evaluated for its ability to predict classifier behavior.

The research question is whether this geometric information remains useful when the classifier itself is unknown.

Natural images are represented in high-dimensional pixel spaces. A grayscale MNIST image, for example, can be represented as a vector in ℝ⁷⁸⁴.

However, meaningful variations in handwritten digits do not necessarily occupy all 784 dimensions independently. Changes in orientation, stroke thickness, translation, and writing style often exhibit structured relationships. The manifold hypothesis suggests that high-dimensional data may concentrate near lower-dimensional geometric structures. Suppose that the source distribution is concentrated near a smooth d-dimensional embedded manifold:

Mₛ ⊂ ℝᴰ, where d ≪ D

Locally, the manifold can be represented using a coordinate chart:

F : U ⊂ ℝᵈ → Mₛ

The differential DF(u) maps a direction in the intrinsic coordinate space to a tangent vector in the ambient space.

At a point a = F(u), the tangent space is given by

**TₐMₛ = Im(DF(u))**

The induced Riemannian metric is

**G(u) = DF(u)ᵀDF(u)**

For a curve γ(t) = F(u(t)) lying on the manifold, its length is determined by this metric:

**L(γ) = ∫₀¹ √[u̇(t)ᵀG(u(t))u̇(t)] dt**

The intrinsic distance between two points is then the infimum of the lengths of curves connecting them on the manifold.

Since the length of any connecting curve is at least the Euclidean distance between its endpoints,

‖x − a‖₂ ≤ dM(a,x) This distinction matters because two points can be close in Euclidean distance while being comparatively distant along the manifold.

Near an anchor point a, the local embedding can be expressed in geodesic normal coordinates as

F(u) = a + Uu + ½IIₐ(u,u) + O(‖u‖³) Here, U spans the tangent space, while IIₐ denotes the second fundamental form, which describes the extrinsic curvature of the manifold. This expression separates local geometric variation into first-order and second-order components. The first-order term describes tangent directions. The second-order term describes how the embedding departs from its tangent-space approximation.

For an orthonormal tangent basis U, the tangent and normal projectors are Pₜ = UUᵀ

Pₙ = I − UUᵀ

Under suitable curvature bounds, the variation of tangent projectors can be controlled by intrinsic distance:

‖Pₜ(x) − Pₜ(a)‖ₒₚ ≤ LₚdM(a,x) Positive reach additionally ensures that points sufficiently close to the manifold have a unique nearest-point projection. These observations motivate the use of local derivatives rather than a single global geometric approximation. However, there is an important distinction: the curvature of the data manifold is not necessarily the curvature of a classifier’s decision boundary, nor does smooth data geometry alone establish that a learned energy Hessian varies slowly.

For that reason, I use manifold geometry as motivation for the construction and evaluate derivative reliability separately. Directly estimating a probability density in a high-dimensional image space is challenging. Score-based generative modeling provides an alternative by estimating derivatives of the log-density rather than the density itself.

For a probability density p(x), its score function is defined as

**s(x) = ∇ₓ log p(x)**

The score describes the local spatial variation of the log-density.

Its Jacobian,

J(x) = ∇ₓs(x) = ∇²ₓ log p(x), contains second-order information about that distribution. To understand why these derivatives might encode geometric information, it is useful to begin with Gaussian smoothing.

Suppose X is a random vector following a class-conditional distribution P꜀.

Introduce an independent Gaussian random vector

Z ∼ N(0,Iᴰ) and define the noisy observation

Y = X + σZ

Conditioned on X = x, the random variable Y follows a multivariate Gaussian distribution:

Y | X = x ∼ N(x,σ²Iᴰ) Its conditional density is

p(y | x) = (2πσ²)⁻ᴰ⁄² exp(−‖y − x‖²/2σ²) The marginal density of Y is obtained by integrating over the original data distribution:

pσ(y) = ∫ p(y | x) dP꜀(x) When the original distribution has a density, this can equivalently be written as a convolution:

pσ = p꜀ ∗ N(0,σ²Iᴰ) Gaussian convolution is particularly useful because the original data distribution might be concentrated on a lower-dimensional manifold and might not possess an ordinary density with respect to the ambient Lebesgue measure. For σ > 0, the Gaussian-smoothed distribution possesses a smooth, strictly positive density throughout the ambient space. Its logarithm, gradient, and Hessian therefore become well-defined. The smoothing parameter σ controls the scale at which the distribution is examined. Small values retain more local structure, while larger values combine information across broader neighborhoods.

I consider a class-conditional scalar energy function Eθ(y,c,σ), from which the score and its Jacobian can be obtained:

**sθ,꜀(y) = −∇ᵧEθ(y,c,σ)**

**Jθ,꜀(y) = −∇²ᵧEθ(y,c,σ)**

The energy can be trained using the denoising score matching objective:

Lᴅꜱᴍ = E[(w(σ)/2) ‖sθ,꜀(X + σZ) + Z/σ‖²] The target term follows directly from differentiating the conditional Gaussian log-density.

Since

log p(y | x) = constant − ‖y − x‖²/(2σ²), we obtain

**∇ᵧ log p(y | x) = (x − y)/σ²**

Using y = x + σz gives

**∇ᵧ log p(y | x) = −z/σ**

The denoising score matching objective therefore trains the model to approximate the conditional Gaussian score. Under squared-error minimization, the optimal prediction is the conditional expectation of this training target given the noisy observation. This conditional expectation equals the marginal score of the Gaussian-smoothed distribution. This allows score estimation without explicitly computing the energy model’s normalization constant.

An important connection between generative modeling and geometry emerges from the optimal denoising problem.

Consider a denoising function Dσ that reconstructs a clean observation X from its noisy version Y.

Under the mean squared error objective,

min_D E[‖X − D(Y)‖²], the optimal denoiser is the posterior mean:

D*σ(y) = E[X | Y = y] This follows from the conditional bias-variance decomposition:

E[‖X − a‖² | Y = y] = tr(Cov(X | Y = y)) + ‖E[X | Y = y] − a‖² The second term is minimized precisely when a equals the posterior mean.

The next question is how this posterior mean relates to the score function.

Starting from the Gaussian-smoothed marginal density,

pσ(y) = ∫ p(y | x) dP꜀(x), differentiate with respect to y:

**∇ᵧpσ(y) = ∫ [(x − y)/σ²] p(y | x) dP꜀(x)**

Dividing by pσ(y) yields

**∇ᵧ log pσ(y) = (E[X | Y = y] − y)/σ²**

Rearranging gives

D*σ(y) = y + σ²∇ᵧ log pσ(y) This is the multivariate Gaussian form of Tweedie’s identity.

It establishes that the optimal denoiser can be recovered from the score of the noisy data distribution.

Equivalently,

**s*σ(y) = (D*σ(y) − y)/σ²**

The score is therefore the normalized displacement from a noisy observation toward its posterior mean. This is particularly interesting because the denoising process is not simply removing noise. It provides information about the conditional distribution of plausible clean observations.

The posterior mean describes the first conditional moment of X given Y.

To obtain second-order information, consider the posterior covariance matrix:

Cσ(y) = Cov(X | Y = y) By definition,

Cσ(y) = E[(X − μ(y))(X − μ(y))ᵀ | Y = y] where

μ(y) = E[X | Y = y] Expanding the expression gives

Cσ(y) = E[XXᵀ | Y = y] − μ(y)μ(y)ᵀ The diagonal entries describe conditional variances, while the off-diagonal entries describe conditional dependence between coordinates. The Gaussian observation model also allows the derivative of the posterior distribution to be expressed as**∇ᵧ log p(x | y) = (x − μ(y))/σ²** where the posterior is interpreted relative to an appropriate underlying measure.

Differentiating the posterior mean coordinate-wise gives

∂μᵢ(y)/∂yⱼ = Cov(Xᵢ,Xⱼ | Y = y)/σ² In matrix form,

DD*σ(y) = Cov(X | Y = y)/σ² Thus, the Jacobian of the optimal denoiser is proportional to the posterior covariance matrix.

Now differentiate Tweedie’s identity:

DDσ(y) = Iᴰ + σ²Jσ(y) Combining the two expressions gives

**Iᴰ + σ²J*σ(y) = Cov(X | Y = y)/σ²**

**J*σ(y) = Cov(X | Y = y)/σ⁴ − Iᴰ/σ²**

This is the mathematical connection between second-order score information and the conditional covariance of the underlying distribution. Since covariance matrices are positive semidefinite,

Iᴰ + σ²J*σ(y) ⪰ 0 It follows that every eigenvalue of the ideal score Jacobian satisfies

λᵢ(J*σ(y)) ≥ −1/σ² The score Jacobian itself, however, need not be positive semidefinite. This distinction becomes important when studying the signed Hessian of a contrast between two distributions.

Consider a simple case in which the clean data follows a multivariate Gaussian distribution:

X ∼ N(μ,Σ) After adding independent isotropic Gaussian noise,

Y ∼ N(μ,Σ + σ²I) The marginal score has a closed-form expression:

sσ(y) = −(Σ + σ²I)⁻¹(y − μ) Its Jacobian is

Jσ(y) = −(Σ + σ²I)⁻¹ The corresponding optimal denoiser is

D*σ(y) = μ + Σ(Σ + σ²I)⁻¹(y − μ) The posterior covariance is

Cov(X | Y = y) = σ²Σ(Σ + σ²I)⁻¹ These expressions agree exactly with Tweedie’s identity and the posterior covariance identity derived above.

Suppose Σ has the spectral decomposition

Σ = UΛUᵀ

Then the score Jacobian has the same eigenvectors, with eigenvalues

λᵢ(Jσ) = −1/(λᵢ(Σ) + σ²) The shifted score Jacobian,

Aσ = I + σ²Jσ,

has eigenvalues

λᵢ(Aσ) = λᵢ(Σ)/(λᵢ(Σ) + σ²) This relationship gives the geometric interpretation. For directions where the data has substantial variation relative to the noise scale, the corresponding eigenvalues of Aσ approach one. For directions where the data has negligible variation, the eigenvalues approach zero. In an ideal locally affine model, if the data has exactly zero variance along normal directions, the corresponding shifted Jacobian eigenvalues are exactly zero. This suggests that the eigenspectrum of the shifted score Jacobian can reveal locally significant directions of data variation.

However, for general nonlinear manifolds and imperfectly learned score functions, this interpretation is approximate rather than exact.

The score is the gradient of a scalar log-density:

s(y) = ∇ log p(y) Consequently, its Jacobian is the Hessian of that scalar function.

For a twice continuously differentiable function, the Clairaut–Schwarz theorem establishes that mixed partial derivatives commute:

**∂² log p(y)/∂yᵢ∂yⱼ = ∂² log p(y)/∂yⱼ∂yᵢ**

Therefore,

**Jᵢⱼ(y) = Jⱼᵢ(y)**

and

J(y) = J(y)ᵀ Clairaut’s theorem and Schwarz’s theorem are commonly used names for this equality of mixed partial derivatives under appropriate regularity conditions. This property also explains why I formulate the learned score through a scalar energy function rather than an unconstrained vector-valued neural network.

For a sufficiently smooth scalar energy,

**sθ(y) = −∇Eθ(y)**

its Jacobian is necessarily symmetric:

Jθ(y) = −∇²Eθ(y) An unconstrained learned vector field does not automatically satisfy this integrability condition. By the spectral theorem, a real symmetric Jacobian admits an orthogonal eigendecomposition:

Jθ(y) = UΛUᵀ All eigenvalues are real, and the eigenvectors can be chosen to form an orthonormal basis. These properties provide the mathematical foundation for the spectral analysis and signed Hessian approximations used later. Nevertheless, estimating the score accurately does not automatically imply that its Jacobian is accurate. Second-order information requires independent numerical and statistical validation.

Instead of studying the source and target distributions independently, I consider their relative behavior within the same input space.

Suppose their Gaussian-smoothed densities are represented by energy-based models:

pθ,꜀(y) = exp[−Eθ(y,c,σ)] / Z꜀ Taking the log-ratio of the prior-weighted densities gives

**log[πₜpθ,ₜ(y) / πₛpθ,ₛ(y)]**

**= Eθ(y,s,σ) − Eθ(y,t,σ) + log(Zₛ/Zₜ) + log(πₜ/πₛ)**

This motivates the raw energy contrast:

gθ(y) = Eθ(y,s,σ) − Eθ(y,t,σ) However, denoising score matching identifies energy gradients without determining class-dependent additive constants.

To see why, consider two energy functions related by

Ẽθ(y,c,σ) = Eθ(y,c,σ) + C꜀ Their gradients are identical because C꜀ is constant with respect to y. Their raw energy contrasts, however, can differ by Cₛ − Cₜ.

Consequently, the zero-level set of the raw energy contrast does not necessarily represent a meaningful class ambiguity surface.

To address this, I introduce a calibrated contrast:

ℓθ(y) = gθ(y) + b̂ The intercept b̂ is estimated using a separate labeled calibration dataset through regularized, prior-weighted logistic regression.

Let rᵢ = +1 denote a target-class observation and rᵢ = −1 denote a source-class observation. The calibration objective is

b̂ = argmin_b [(1/Ncal) Σᵢ wᵢ log(1 + exp(−rᵢ(gθ(yᵢ) + b))) + λᵦb²/2] The sample weights account for the specified class priors, while the regularization parameter is selected using development data. If the estimated energies recover the true log-density ratio up to an additive constant, an appropriate intercept can recover the corresponding discriminant offset. Otherwise, calibration provides an empirical correction without necessarily resolving errors in the spatial variation of the energies.

The first and second derivatives of the calibrated contrast are

**hθ(y) = ∇ℓθ(y) = sθ,ₜ(y) − sθ,ₛ(y)**

**Kθ(y) = ∇²ℓθ(y) = Jθ,ₜ(y) − Jθ,ₛ(y)**

Since the calibration intercept is constant with respect to y, it changes the location of the zero-level set without changing either derivative.

For ideal Gaussian-smoothed class distributions, Tweedie’s identity gives

**s*ₜ(y) = (μₜ(y) − y)/σ²**

**s*ₛ(y) = (μₛ(y) − y)/σ²**

where μ꜀(y) is the class-conditional posterior mean.

Subtracting these identities yields

h(y) = (μₜ(y) − μₛ(y))/σ²* The gradient of the ideal class contrast is therefore determined by the difference between the two class-conditional posterior means.

Similarly, from the posterior covariance identity,

**J*ₜ(y) = Cₜ(y)/σ⁴ − I/σ²**

**J*ₛ(y) = Cₛ(y)/σ⁴ − I/σ²**

Subtracting gives

K(y) = (Cₜ(y) − Cₛ(y))/σ⁴* The isotropic correction terms cancel because the two classes use the same Gaussian smoothing scale.

This provides a direct mathematical interpretation of both derivatives:

Although each covariance matrix is positive semidefinite, their difference is not necessarily positive semidefinite. This explains why the signed eigenvalue structure of the class-contrast Hessian is relevant. These identities hold for the ideal smoothed densities. The learned quantities approximate them, and the accuracy of those approximations must be evaluated.

I define the generative class ambiguity surface as

Bɢ = {y ∈ ℝᴰ : ℓθ(y) = 0} This is the central geometric object in the proposed approach. The question is not whether Bɢ is the classifier’s decision boundary. It is whether the local structure of Bɢ provides useful information about where the classifier’s boundary might be located.

The calibrated contrast is a scalar function defined over the ambient input space.

Suppose that z lies on Bɢ and that

**ℓθ(z) = 0, ∇ℓθ(z) ≠ 0**

If ℓθ is twice continuously differentiable near z, the Implicit Function Theorem establishes that Bɢ is locally a smooth (D − 1)-dimensional embedded hypersurface. The reason is that at least one partial derivative of ℓθ must be nonzero.

Locally, the corresponding coordinate can therefore be expressed as a differentiable function of the remaining D − 1 coordinates. Consider a differentiable curve γ(t) lying entirely on the ambiguity surface, with γ(0) = z.

ℓθ(γ(t)) = 0, differentiating through the chain rule gives

hθ(z)ᵀγ̇(0) = 0 Its tangent space is therefore

T_zBɢ = {v ∈ ℝᴰ : hθ(z)ᵀv = 0} The unit normal is

nɢ(z) = hθ(z)/‖hθ(z)‖ The orthogonal tangent-space projector is therefore

Pɢ(z) = Iᴰ − nɢ(z)nɢ(z)ᵀ The gradient describes the local normal direction of the generative ambiguity surface. At points where the gradient vanishes, the regularity condition fails, and this normal representation is undefined.

To understand how the normal changes along the surface, we differentiate it in tangent directions.

Starting from

nɢ(z) = hθ(z)/‖hθ(z)‖, the directional derivative of the normalized gradient is

Dᵥnɢ(z) = Pɢ(z)Kθ(z)v/‖hθ(z)‖ Under the convention IIɢ(v,w) = ⟨Dᵥnɢ,w⟩, the matrix representation of the second fundamental form restricted to the tangent space is

**IIɢ ↔ Pɢ(z)Kθ(z)Pɢ(z) / ‖hθ(z)‖**

For a unit tangent direction v, the corresponding signed normal curvature under this convention is

**κₙ(v) = vᵀKθ(z)v/‖hθ(z)‖**

This connects the signed Hessian of the class contrast to the local curvature of its zero-level surface. The tangent-space projection and gradient normalization are essential: the full Hessian alone is not the curvature tensor of the hypersurface. Another important observation is that Kθ is a difference between two score Jacobians. Although it is symmetric under the assumed differentiability conditions, it need not be positive semidefinite. Its positive and negative eigenvalues therefore describe different forms of directional second-order variation. These properties motivate examining whether second-order information provides a better local description than the gradient alone.

It is also important to distinguish the three geometric objects involved in this research:

The curvature of one object cannot automatically be identified with the curvature of another.

Near an input x, Taylor’s theorem gives

ℓθ(x + δ) = ℓθ(x) + hθ(x)ᵀδ + ½δᵀKθ(x)δ + R₃(x,δ) When the Hessian is locally Lipschitz continuous,

R₃(x,δ) = O(‖δ‖³) More precisely, suppose that

‖Kθ(x + δ) − Kθ(x)‖ₒₚ ≤ Lₖ‖δ‖ throughout the relevant neighborhood.

Then the Taylor remainder satisfies

|R₃(x,δ)| ≤ (Lₖ/6)‖δ‖³ A first-order approximation retains only the scalar value and gradient. A second-order approximation additionally retains the quadratic term involving the Hessian.

Along a unit direction v, let δ = τv. The first-order approximation becomes

ℓθ(x + τv) ≈ ℓθ(x) + τhθ(x)ᵀv The second-order approximation becomes

ℓθ(x + τv) ≈ ℓθ(x) + τhθ(x)ᵀv + ½τ²vᵀKθ(x)v The difference between these approximations is determined by the directional second derivative:

**vᵀKθ(x)v**

If the contrast varies approximately linearly in a neighborhood, first-order information may be sufficient. If its variation is substantially nonlinear, the second-order term may improve the predicted location of its zero-level crossing.

This leads to my first research hypothesis:

Does including the signed Hessian improve the prediction of an independently trained classifier’s boundary when first-order and second-order methods are evaluated along identical directions?

Matching the directions is essential. Otherwise, an observed improvement could result from better direction selection rather than the second-order approximation itself. The generative prediction must ultimately be evaluated against the independently trained classifier. Mathematical accuracy with respect to the generative surface alone is insufficient.

Before moving to high-dimensional images, I investigated this question using the two-moons dataset.

The dataset provides two nonlinear class distributions within a two-dimensional space, allowing the generative ambiguity surface and classifier decision boundaries to be examined directly. For these initial experiments, the class densities were represented using Gaussian mixtures rather than neural energy-based models. The purpose was to establish whether the geometric hypothesis was plausible in a controlled environment before introducing the additional uncertainty associated with learning high-dimensional energy functions.

A single multivariate Gaussian distribution is generally insufficient for representing a nonlinear distribution such as two moons.

A Gaussian mixture model represents a density as a weighted combination of multiple Gaussian components:

p(x) = Σₖ αₖ N(x;μₖ,Σₖ) αₖ ≥ 0, Σₖαₖ = 1

Each component has its own mean and covariance matrix.

For a Gaussian component with positive-definite covariance Σₖ, its density is

**N(x;μₖ,Σₖ) = [(2π)ᴰᐟ² det(Σₖ)¹ᐟ²]⁻¹ exp[−½(x − μₖ)ᵀΣₖ⁻¹(x − μₖ)]**

The quadratic term is the squared Mahalanobis distance from the component mean. Unlike an ordinary Euclidean distance, it accounts for the covariance structure of the distribution.

Define the component responsibility

rₖ(x) = αₖN(x;μₖ,Σₖ)/p(x) The score of an individual Gaussian component is

gₖ(x) = −Σₖ⁻¹(x − μₖ) The mixture score is then the responsibility-weighted average of the component scores:

s(x) = Σₖ rₖ(x)gₖ(x) Differentiating again yields the mixture score Jacobian:

**J(x) = −Σₖ rₖ(x)Σₖ⁻¹ + Covᵣ(gₖ(x))**

Here,

**Covᵣ(gₖ(x)) = Σₖ rₖ(x)(gₖ(x) − s(x))(gₖ(x) − s(x))ᵀ**

The first term captures the responsibility-weighted curvature within individual components. The second term captures variation between their score vectors. Consequently, the log-density of a Gaussian mixture can exhibit more complicated local curvature than that of a single Gaussian distribution. Gaussian mixtures also remain Gaussian mixtures under isotropic Gaussian convolution: each covariance Σₖ becomes Σₖ + σ²I, while the component weights and means remain unchanged. These analytical properties make Gaussian mixtures useful for controlled studies of the score, Hessian, and class-density contrast without introducing neural derivative estimation errors.

The independently trained classifiers included:

The larger experiment used 120 shared, correctly classified source points.

One observation from this visualization is that the generative ambiguity surface and the classifier’s boundary are geometrically related in some regions but differ in others. This is precisely why their correspondence must be evaluated empirically.

The exact second-order approximation produced closer verified target-side crossings than the first-order approximation in the following number of paired cases:

The results suggest that second-order information can improve localization in these controlled synthetic settings.

I also measured the median radial prediction error along matched directions.

The reduction in radial prediction error provides preliminary evidence that the second-order structure of a generative contrast can contain information relevant to an independent classifier’s boundary.

However, better boundary localization does not necessarily imply greater query efficiency.

This was one of the more interesting observations from the experiment.

Although the second-order method produced slightly lower mean query counts, the confidence intervals for these differences included zero.

At a perturbation budget of ε = 0.4, the targeted success rates were:

These are exploratory findings rather than confirmatory results. At this stage, the evidence is considerably stronger for improved boundary localization than for reduced classifier queries. This distinction suggests that geometric prediction accuracy and practical search efficiency should be treated as separate research objectives.

Even if second-order information improves localization, computing it introduces another challenge.

For an input in ℝᴰ, the Hessian is a D × D matrix.

For MNIST, D = 784. For CIFAR-10, D = 3072. Explicitly computing and decomposing a dense Hessian for every image becomes increasingly expensive as the input dimension grows. Instead of independently computing second-order information at every point, I am investigating whether locally reliable Hessian approximations can be reused.

The idea is to construct an atlas of representative anchor points.

Since the contrast Hessian is symmetric, the spectral theorem allows it to be written as

Kθ(a) = UΛUᵀ where U is an orthogonal matrix and Λ contains the signed eigenvalues.

Kθ(a) = Σᵢ λᵢuᵢuᵢᵀ Each eigenpair describes second-order variation along its corresponding eigendirection.

For an arbitrary unit vector v,

**vᵀKθ(a)v = Σᵢ λᵢ(uᵢᵀv)²**

This expression explains how the signed eigenvalues contribute to directional second-order variation.

A low-rank approximation retains a subset of these eigenpairs:

K̂ᵣ(a) = Uᵣ(a)Λᵣ(a)Uᵣ(a)ᵀ where Uᵣ contains orthonormal eigenvectors and Λᵣ contains their signed eigenvalues.

For an exact spectral truncation of a symmetric matrix, the operator-norm error equals the largest absolute omitted eigenvalue. Hessian-vector products and Lanczos-based spectral approximation provide a way to investigate these eigenspaces without explicitly constructing the entire dense Hessian. For a nearby point x, the reliability of the approximation depends on both the truncation error at the anchor and the variation of the Hessian between a and x. The Hessian-vector product can be expressed as the derivative of a directional gradient:

**Kθ(a)v = ∇ₐ[hθ(a)ᵀv]**

for a fixed vector v.

Automatic differentiation allows this quantity to be evaluated without explicitly storing the full Hessian matrix. The Lanczos method exploits repeated matrix-vector products to construct an orthonormal basis for a Krylov subspace:

𝒦ₘ(K,v) = span{v,Kv,K²v,…,Kᵐ⁻¹v} Projecting a symmetric operator onto this subspace produces a smaller symmetric tridiagonal matrix whose eigendecomposition can be used to approximate selected eigenpairs of the original operator. In the proposed approach, both positive and negative spectral components are considered, since the contrast Hessian is not generally positive semidefinite. Numerical eigenpair residuals and spectral separation must be checked before using these approximations.

Suppose the Hessian at a neighboring point can be written as

Kθ(x) = Kθ(a) + E where E represents the local matrix perturbation.

For ordered eigenvalues of symmetric matrices, Weyl’s inequality gives

**|λᵢ(Kθ(x)) − λᵢ(Kθ(a))| ≤ ‖E‖ₒₚ**

This controls the variation of eigenvalues.

Eigenvalue stability, however, does not necessarily imply eigenvector stability. For example, eigenvectors associated with nearly repeated eigenvalues may rotate considerably under relatively small perturbations. Suppose the relevant eigenspaces are separated by an eigengap γₐ > 0. Under appropriate spectral separation conditions, the Davis–Kahan theorem provides a bound of the form

**‖Pᵣ(x) − Pᵣ(a)‖ₒₚ ≤ 2‖Kθ(x) − Kθ(a)‖ₒₚ/γₐ**

**Pᵣ(a) = Uᵣ(a)Uᵣ(a)ᵀ**

This relates the rotation of the retained eigenspace to the perturbation of the underlying Hessian. A sufficiently large eigengap and small Hessian variation can support local spectral stability. However, spectral stability does not establish that an eigenspace represents meaningful data geometry. It only controls the variation of the estimated eigenspace.

To evaluate whether an anchor’s Hessian remains useful in its neighborhood, I consider four complementary diagnostics:

Gradient transport error: How accurately does the anchor Hessian predict the variation of the class-contrast gradient?

Let

Δ = x − a

By the fundamental theorem of calculus applied along the line segment connecting a and x,

hθ(x) − hθ(a) = ∫₀¹ Kθ(a + tΔ)Δ dt Approximating the Hessian along this segment by its cached anchor value gives

h̃ₐ(x) = hθ(a) + K̂ᵣ(a)Δ A normalized transport error can then be defined as

eₕ = ‖hθ(x) − h̃ₐ(x)‖ / (‖hθ(x)‖ + ‖h̃ₐ(x)‖ + η₀) Scalar prediction error

Using the anchor’s local quadratic approximation,

**ℓ̃ₐ(x) = ℓθ(a) + hθ(a)ᵀΔ + ½ΔᵀK̂ᵣ(a)Δ**

the corresponding normalized scalar prediction error is

eₗ = |ℓθ(x) − ℓ̃ₐ(x)| / (|ℓθ(x)| + |ℓ̃ₐ(x)| + η₀) Signed Hessian fidelity

The operator-level discrepancy is measured using

eₖ = ‖Kθ(x) − K̂ᵣ(a)‖ₒₚ / (‖Kθ(x)‖ₒₚ + ‖K̂ᵣ(a)‖ₒₚ + η₀) This assesses whether the cached matrix adequately represents the local second-order structure.

Projector agreement

The retained eigenspaces are compared through their orthogonal projectors:

eₚ = ‖Pᵣ(x) − Pᵣ(a)‖ₒₚ These diagnostics examine different aspects of local reliability. An anchor could have a stable dominant eigenspace while failing to predict the local gradient accurately. Conversely, accurate gradient transport in one direction does not establish uniform operator-level agreement.

The proposed audit therefore evaluates all four quantities.

Evaluating every member of every anchor neighborhood can itself become computationally expensive.

Instead, consider a frozen neighborhood containing Mₐ members. Draw mₐ members uniformly without replacement. A member is marked as unreliable if any of its four diagnostic errors exceeds the corresponding predetermined tolerance.

Let π̂ₐ denote the observed fraction of unreliable members. Because the sampling is performed without replacement from a finite population, a Serfling-style concentration bound can be used.

For mₐ < Mₐ, define

**ξₐ = √{[1 − (mₐ − 1)/Mₐ] log(1/δₐ)/(2mₐ)}**

For a complete census, ξₐ is set to zero.

With the corresponding confidence guarantee, the true unreliable fraction of the frozen neighborhood is bounded above by

πₐ ≤ π̂ₐ + ξₐ

An anchor is accepted only if

π̂ₐ + ξₐ ≤ β

and its numerical spectral checks pass.

Here, β is the maximum tolerated fraction of unreliable neighborhood members. When multiple anchors and candidate configurations are examined, the allocated error probabilities must be controlled collectively. Such an audit does not provide a uniform guarantee for arbitrary future images. Its predictive usefulness must be established on separate held-out data.

For a nearby source point x, consider the anchor-based quadratic model

**qₓ₍ₐ₎(δ) = ℓθ(x) + hθ(x)ᵀδ + ½δᵀK̂ᵣ(a)δ**

The scalar contrast and gradient are evaluated at x itself. Only the Hessian is reused.

Suppose the anchor approximation satisfies

‖Kθ(a) − K̂ᵣ(a)‖ₒₚ ≤ εₜᵣ and the Hessian is locally Lipschitz with constant Lₖ.

For points satisfying ‖x − a‖ ≤ ρₐ, the triangle inequality gives

**‖Kθ(x) − K̂ᵣ(a)‖ₒₚ ≤ Lₖρₐ + εₜᵣ**

Combining this inequality with the Taylor remainder bound yields

**|ℓθ(x + δ) − qₓ₍ₐ₎(δ)|**

**≤ ½(εₜᵣ + Lₖρₐ)‖δ‖² + (Lₖ/6)‖δ‖³**

This bound separates three sources of approximation error:

It also explains why the anchor radius and the prediction radius serve different mathematical purposes. The first controls derivative reuse, while the second controls the validity of the local approximation.

In the synthetic experiment, I examined configurations containing 12, 24, 48, and 96 representative anchors.

Using 24 anchor Hessians instead of 120 independently evaluated Hessians reduced the number of Hessian evaluation locations by 80%. The resulting verified crossing distances remained within 0.02 of the exact second-order results in 94.2%, 93.3%, and 95.8% of paired cases across the three classifiers. Although these observations are encouraging, they do not establish an 80% reduction in computational runtime. The experiment involved inexpensive two-dimensional Gaussian mixture derivatives. Neural energy models in high-dimensional input spaces may exhibit substantially different computational and numerical behavior.

Furthermore, the 24-anchor configuration was fixed during this experiment. A prospective evaluation must independently select the anchor count using reliability, coverage, and total amortized cost.

A central limitation of this research is that generative accuracy does not necessarily imply discriminative accuracy.

To illustrate the distinction, suppose that the hidden classifier margin can locally be represented as

mꜰ(x) = αℓθ(x) + rꜰ(x) where α > 0 and rꜰ describes the discrepancy between the classifier’s discriminative margin and the learned generative contrast. If rꜰ is small within a relevant neighborhood, a zero of ℓθ may lie close to a zero of mꜰ.

For a fixed direction v, suppose that the discriminative margin has a root at τꜰ and its directional derivative is bounded away from zero throughout the relevant segment:

**|d mꜰ(x + τv)/dτ| ≥ μ > 0**

Let τɢ denote a root of the generative contrast along the same direction.

By the Mean Value Theorem, there exists an intermediate point ξ such that

mꜰ(x + τɢv) − mꜰ(x + τꜰv) = m′ꜰ(ξ)(τɢ − τꜰ) Since the discriminative margin vanishes at τꜰ and the generative contrast vanishes at τɢ,

mꜰ(x + τɢv) = rꜰ(x + τɢv) It follows that

|τɢ − τꜰ| ≤ |rꜰ(x + τɢv)|/μ This requires the relevant roots and regularity conditions to hold on the same segment.

The relationship is useful conceptually because it identifies two distinct factors:

It also explains why an accurate generative approximation may fail to predict a classifier boundary. Even if the Taylor approximation error is negligible, the discrepancy rꜰ may remain large. Similarly, a nearly vanishing directional derivative can make root localization unstable. The difficulty is that these quantities are generally unavailable in a strict hard-label setting. Determining when their effects are sufficiently controlled is therefore an empirical research problem.

The next stage separates the investigation into three hypotheses.

H1 — Predictive value of curvature. Does incorporating second-order information improve boundary localization relative to a matched first-order approximation?

H2 — Reliability and computational amortization. Can audited anchor-based Hessian approximations preserve prediction quality while reducing total computational cost?

H3 — Practical query efficiency. Does improved boundary localization translate into fewer classifier queries without substantially reducing targeted success?

These hypotheses are related, but none automatically follows from the others. A method could improve boundary localization without reducing queries. Similarly, an anchor atlas might preserve localization accuracy while introducing enough construction and audit overhead to eliminate its computational advantage. The planned experiments will progress from synthetic distributions to MNIST and subsequently to natural-image datasets such as CIFAR-10, provided the earlier results support that progression. The evaluation will distinguish between generative calibration accuracy, derivative fidelity, boundary prediction error, targeted success, query consumption, and computational cost.

The prospective evaluation criteria include paired statistical comparisons, confidence intervals, non-inferiority testing for targeted success, and Holm-adjusted hypothesis tests to control the familywise type I error rate. All final evaluations will use independently trained classifiers and held-out data, with any external model testing restricted to explicitly authorized settings.

Several limitations remain unresolved.

First, the assumption that natural images concentrate near smooth, locally regular manifolds may only provide an approximate description of real data.Second, second-order derivatives obtained from learned energy models may be unreliable even when the score matching objective performs well.Third, Euclidean proximity between images does not necessarily imply semantic or geometric similarity. Representation-based neighborhoods may offer a useful alternative, but their reliability also requires empirical validation.Fourth, the generative ambiguity surface may systematically differ from the discriminative decision boundary because of architecture, training objectives, preprocessing, and finite-sample effects.Fifth, small pixel-space perturbations do not establish that image semantics have been preserved.

These limitations suggest several broader questions:

Answering these questions may be as valuable as improving the efficiency of a particular adversarial search method.

This investigation began with a relatively simple question: can information learned about the distribution of data tell us something about the decision boundary of an independently trained classifier?

The mathematical formulation suggests that a calibrated contrast between class-conditional energy functions provides a useful object for studying this relationship. Tweedie’s identity connects the score to the optimal denoiser, while differentiation of the posterior mean connects the score Jacobian to posterior covariance. Taking the difference between two class-conditional scores therefore provides information about the difference between their posterior means. Taking the difference between their Jacobians provides information about the difference between their posterior covariance structures. Its gradient describes the local normal direction of the generative ambiguity surface, while its signed Hessian provides information about second-order variation and, through tangent-space projection, the surface’s curvature. The preliminary synthetic experiments indicate that this second-order information can improve boundary localization across multiple independently trained classifiers.

However, meaningful reductions in classifier queries have not yet been established, and the computational feasibility of reliable Hessian reuse in high-dimensional image spaces remains an open question. For me, the most interesting outcome is not necessarily a more efficient adversarial method. It is a better understanding of how the geometry learned by a generative model relates to the decision geometry learned by a discriminative model. Even if that relationship holds only within particular data regimes, identifying those conditions would provide useful insight into the behavior and robustness of learned classifiers.

Can the Shape of Data Predict Where a Classifier’s Decision Boundary Is? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #machine-learning 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/can-the-shape-of-dat…] indexed:0 read:31min 2026-12-02 · —