---
title: 'Sliced Score Matching: Scalable Density Estimation'
url: https://www.emergentmind.com/topics/sliced-score-matching-ssm
type: topic
---

# Sliced Score Matching: Scalable Density Estimation

Sliced score matching (SSM) is a scalable method for density and score estimation in unnormalized statistical models. It generalizes Hyvärinen's score matching by projecting the score function onto random directions, avoiding the need to compute a full Hessian trace and enabling efficient estimation in high-dimensional and deep models. SSM is widely applicable across probabilistic modeling, implicit generative models, and high-dimensional stochastic differential equations.

## 1. Mathematical Formulation of Sliced Score Matching

Let \( p_d(x) \) be the data distribution over \( \mathbb{R}^d \), and \( p(x; \theta) \) an unnormalized model with score \( s_\theta(x) = \nabla_x \log p(x; \theta) \). The original score matching loss of Hyvärinen can be written (up to an additive constant) as:
\[
J_{\mathrm{SM}}(\theta) = \mathbb{E}_{x \sim p_d}\left[ \mathrm{Tr}(\nabla_x s_\theta(x)) + \frac{1}{2}\|s_\theta(x)\|^2 \right].
\]
Direct computation of the trace \( \mathrm{Tr}(\nabla_x s_\theta(x)) \) is computationally expensive in high dimensions.

SSM replaces the trace with an expectation over random projections using a vector \( v \sim p_v \) with \( \mathbb{E}[v v^\top] = I \):
\[
J_{\mathrm{SSM}}(\theta) = \mathbb{E}_{x \sim p_d} \, \mathbb{E}_{v \sim p_v} \left[ v^\top \nabla_x s_\theta(x) v + \frac{1}{2} (v^\top s_\theta(x))^2 \right] + \text{const},
\]
with \( \mathbb{E}_v [v^\top \nabla_x s_\theta(x) v] = \mathrm{Tr}(\nabla_x s_\theta(x)) \) by the Hutchinson estimator. The empirical estimator uses i.i.d. data \( \{x_i\} \) and projections \( \{v_{ij}\} \):
\[
\widehat{J}_{\mathrm{SSM}}(\theta) = \frac{1}{N M} \sum_{i=1}^N \sum_{j=1}^M \left[ v_{ij}^\top \nabla_x s_\theta(x_i) v_{ij} + \frac{1}{2} (v_{ij}^\top s_\theta(x_i))^2 \right].
\]
A variance-reduced version (SSM-VR) substitutes the quadratic term by its expectation \( \frac{1}{2}\|s_\theta(x)\|^2 \) for appropriate \( v \) [1905.07088].

## 2. Theoretical Guarantees and Statistical Properties

Under standard regularity assumptions (positivity of \( p \), smoothness of \( s_\theta \), compact parameter set, etc.), SSM has the following properties [1905.07088]:
- **Consistency**: The minimizer of \( \widehat{J}_{\mathrm{SSM}} \) converges in probability to the population minimizer as \( N \to \infty \) for fixed number of projections \( M \).
- **Asymptotic Normality**: For sufficiently smooth models,
  \[
  \sqrt{N}(\hat{\theta}_{N, M} - \theta^*) \overset{d}{\longrightarrow} \mathcal{N}\left(0, [\nabla^2_\theta J(\theta^*)]^{-1} \Sigma [\nabla^2_\theta J(\theta^*)]^{-1}\right),
  \]
  where \( \Sigma \) is the variance of the gradient of the SSM loss.
- As \( M \to \infty \), variance matches exact score matching.

These results situate SSM within classical empirical risk minimization, ensuring reliability for large-scale learning tasks.

## 3. Computational Implementation and Projection Choices

SSM is amenable to efficient algorithmic implementation, primarily relying on Hessian-vector products that can be evaluated by reverse-mode automatic differentiation. In frameworks like PyTorch or TensorFlow, one computes:
- \( s = \nabla_x \log p(x; \theta) \)
- \( g = \nabla_x (v^\top s) \)
- Then \( v^\top \nabla_x s v = v^\top g \)
This requires two backward passes per projection, and the complexity is \( O(M) \) reverse-mode calls, independent of the ambient dimension \( d \) as long as \( M \ll d \).

Common projection distributions include:
- Isotropic Gaussian (\( v \sim \mathcal{N}(0, I) \)): straightforward to sample, higher variance due to \( \mathbb{E}[v_i^4] = 3 \)
- Uniform on sphere (\( \|v\|=1 \)): reduced fourth moments, lowers estimator variance at a slight computational overhead

Any distribution with \( \mathbb{E}[v v^\top] = I \) can be used [1905.07088].

## 4. Extensions: Generalized Sliced Score Matching

Recent work extends SSM to arbitrary smooth “slices” (\( v(x) \)), not just linear projections [2412.07904]. The generalized SSM (GSSM) objective,
\[
\mathcal{L}_{\mathrm{GSSM}}(s_\theta) = \frac{1}{2} \mathbb{E}_{x, v} \left[ (\nabla_x v(x)^\top s_\theta(x))^2 \right] + \mathbb{E}_{x, v} \left[ \nabla_x v(x)^\top \nabla_x (s_\theta(x) \nabla_x v(x)) \right] + \ldots
\]
includes Hessian and Laplacian terms arising from nonlinear \( v \). For linear \( v(x) = v^\top x \), one recovers standard SSM.

GSSM allows the use of nonlinear projections, resulting in greater flexibility and potential for bias reduction, at the cost of increased variance and sample complexity. Empirical studies demonstrate that, on certain high-dimensional problems, GSSM and its variance-reduced version outperform standard SSM in score-matching and test log-likelihood [2412.07904].

## 5. Applications in Modern Machine Learning

SSM and its generalizations have been deployed in several advanced contexts:
- **Deep Energy-Based Models**: SSM enables training deep kernel exponential families, outperforming denoising score matching and other Hessian-free approximations on UCI benchmarks. It scales to high-dimensional flows (e.g., NICE on MNIST, 784D) where exact score matching is prohibitively slow [1905.07088].
- **Implicit Likelihood Models**: SSM provides superior or competitive scores compared to Stein and spectral kernel methods in variational auto-encoding with implicit encoders, achieving improved negative test log-likelihood and FID metrics [1905.07088].
- **Wasserstein Auto-Encoders**: Tighter divergence matching between posterior and prior is achieved using SSM, yielding higher synthetic sample quality [1905.07088].
- **High-Dimensional SDEs and Fokker–Planck Equations**: SSM serves as a core loss in score-based solvers for high-dimensional Fokker–Planck PDEs, maintaining accuracy and scaling linearly with dimension. Coupled with ODE-based log-likelihood inference, it enables tractable evaluation and sampling up to hundreds of dimensions [2402.07465].

The following table summarizes key application domains and their main SSM-driven advances:

| Domain             | Model/Context          | SSM Impact                        |
|--------------------|-----------------------|-----------------------------------|
| Deep EBMs          | Kernel Exp. Family    | Efficient, scalable learning      |
| Implicit VAEs      | Score Estimation      | Outperforms kernel/Stein methods  |
| WAE                | Aggregated posterior  | Tighter KL, improved samples      |
| SDEs/Fokker–Planck | High-dimensional SDEs | Robust, linear scaling in dim.    |

## 6. Limitations and Practical Considerations

Principal limitations and operational factors include:
- **Trace estimation variance**: For very high \( d \), stochastic (Hutchinson-type) trace estimators introduce variance that may slow convergence or degrade final accuracy [2402.07465].
- **Boundary and Heavy-Tailed Failures**: In SDEs with heavy-tailed or otherwise pathological distributions, the SSM loss can diverge, typically due to ill-posed conditional scores at domain boundaries. In such cases, PDE-based regularization (e.g., Score-PINN) is more robust [2402.07465].
- **Comparison with Standard Score Matching**: While SSM is slightly less efficient per iteration than direct SM (due to higher-order differentiation), it applies in cases where conditional densities are unknown, and SM is not available.
- **Projection Distribution Trade-offs**: Uniform sphere projections reduce variance but require normalization, while Gaussian projections are computationally simpler [1905.07088].

A plausible implication is that, in practice, selecting the projection distribution and the number of projections is task-dependent, balancing computational budget and estimator variance.

## 7. Outlook and Recent Developments

The extension from linear projections in SSM to arbitrary smooth “slicing” functions in GSSM expands the methodology’s adaptability [2412.07904]. This generalization leverages change-of-variable identities for the score, supporting richer classes of projections that can reduce bias at some increase in estimator variance and sample requirements.

Empirical investigations demonstrate that variance-reduced versions of GSSM can both stabilize training and outperform linear SSM in certain real-data scenarios (e.g., deep kernel exponential families on UCI datasets). These findings suggest that leveraging non-linear, data-adaptive projections may become increasingly important for high-dimensional or structured data distributions [2412.07904].

Together, these results establish SSM as a core tool for score-based estimation in modern unnormalized modeling and provide a methodological foundation for its further extension to complex, high-dimensional, and implicit learning problems.

Source: https://www.emergentmind.com/topics/sliced-score-matching-ssm