---
title: Walsh-Hadamard Neural Operators (WHNO)
url: https://www.emergentmind.com/topics/walsh-hadamard-neural-operators-whno
type: topic
---

# Walsh-Hadamard Neural Operators (WHNO)

The Walsh-Hadamard Neural Operator (WHNO) is a spectral neural operator constructed to approximate solution operators of partial differential equations (PDEs) characterized by discontinuous coefficients or sharp solution features. Unlike standard spectral neural operators based on Fourier transforms, which are highly effective for smooth fields but susceptible to the Gibbs phenomenon around discontinuities, the WHNO leverages the Walsh-Hadamard transform—a basis of orthonormal, piecewise-constant rectangular functions—enabling high-fidelity representation of abrupt jumps and interfaces without spectral ringing. The architecture comprises learnable spectral weights acting on low-sequency Walsh coefficients to capture nonlocal dependencies, followed by a convolutional decoder. Empirical results demonstrate WHNO’s superiority over Fourier-based neural operators when sharp material interfaces are present and further reveal that ensembles combining WHNO and FNO exploit complementary representational properties, achieving substantial error reductions for a suite of benchmark PDEs with discontinuities [2511.07347].

## 1. Mathematical Foundations

### 1.1 Walsh–Hadamard Basis and Transform

The Walsh functions $\{w_k(x)\}_{k=0}^{\infty}$ constitute an orthonormal basis on $[0,1]$, each function a rectangular wave taking values in $\pm1$. Unlike sinusoids, Walsh functions are sequency-ordered: $w_k$ has $k$ zero-crossings, correlating low $k$ with broad, constant regions and high $k$ with rapid alternation.

For vectors $f \in \mathbb{R}^n$, the (normalized) Hadamard matrix $H_n \in \{\pm1\}^{n \times n}$ (with $n=2^m$) underpins the discrete Walsh-Hadamard Transform (WHT). Key definitions:
  - $H_1 = [1]$
  - $H_{2n} = \begin{pmatrix} H_n & H_n \\ H_n & -H_n \end{pmatrix}$
  - $\tilde{H}_n = H_n/\sqrt{n}$ (orthonormalization)
  - One-dimensional WHT: $\hat{f} = \tilde{H}_n f$, with $\tilde{H}_n^{-1} = \tilde{H}_n$.

The WHT for $f(x)$ (continuous, $f \in L^2[0,1]$):

\[
\mathcal{W}[f](k) = \int_0^1 f(x) w_k(x) dx, \qquad
f(x) = \sum_{k=0}^\infty \mathcal{W}[f](k) w_k(x)
\]

For discrete $f$ on $n$ grid points $x_j$:

\[
\mathcal{W}[f](k) = \frac{1}{n} \sum_{j=0}^{n-1} f(x_j) w_k(x_j),
\quad
f(x_j) = \sum_{k=0}^{n-1} \mathcal{W}[f](k) w_k(x_j)
\]

The two-dimensional (2D) transform uses WHT along each axis. The Fast Walsh-Hadamard Transform (FWHT) computes this in $O(n \log n)$ time.

### 1.2 Relationship to PDE Discontinuities

Walsh basis functions are uniquely suited to representing piecewise-constant features common in heterogeneous PDEs. The presence of sharp jumps or interfaces yields a sparse Walsh spectrum, supporting efficient low-sequency truncation without significant interface distortion. In contrast, the Fourier basis incurs oscillatory artifacts (Gibbs phenomenon) near discontinuities—requiring orders of magnitude more modes for comparable sharpness.

## 2. Operator Architecture

### 2.1 High-Level Pipeline

Given a coefficient field $a(x)$ on a $h \times w$ grid ($h$, $w$ powers of 2), the WHNO workflow:

1. **Input Lifting**: Construct $x^{(0)} = \mathrm{Concatenate}[a(x), 1(x)] \in \mathbb{R}^{h \times w \times 2}$.

2. **Spectral Layers** (typically two):

   - **Forward 2D WHT**: $\hat{x}^{(\ell-1)} = \mathrm{WHT}_2(x^{(\ell-1)}) = \tilde{H}_h x^{(\ell-1)} \tilde{H}_w^\top$
   - **Spectral Truncation**: Retain only $k \times k$ lowest-sequency coefficients: $\hat{x}^{(\ell-1)}_{[0:k,0:k]} \in \mathbb{R}^{k \times k \times c_{\text{in}}}$
   - **Learnable Spectral Weights**: Affine mixing in spectral domain:
     \[
     \widehat{v}^{(\ell)}_{i,j,m} = \sum_{\ell'=1}^{c_{\text{in}}} W^{(\ell)}_{i,j,\ell',m} \hat{x}^{(\ell-1)}_{i,j,\ell'} + b^{(\ell)}_{i,j,m}
     \]
   - **Zero Padding**: Expand to $h \times w$
   - **Inverse WHT**: $v^{(\ell)} = \mathrm{WHT}_2^{-1}(\widehat{v}^{(\ell)})$

3. **Spatial Mixing & Skip Connections**: First layer, no skip; second layer, residual: $x^{(2)} = v^{(2)} + x^{(1)}$.

4. **Decoder**: Several dilated 2D convolutions act on $\mathrm{Concatenate}[x^{(2)}, a]$ to yield output $u(x)$.

### 2.2 Spectral-Layer Formulae

Let $\ell$ indicate layer index:

\[
\begin{aligned}
\widehat{u}^{(\ell-1)} &= \mathrm{WHT}_2(u^{(\ell-1)}) \\
\widehat{u}^{(\ell-1)}_{[:k,:k]} &= \mathrm{Truncate}_k(\widehat{u}^{(\ell-1)}) \\
\widehat{v}^{(\ell)}_{i,j} &= W^{(\ell)}_{i,j} \widehat{u}^{(\ell-1)}_{i,j} + b^{(\ell)}_{i,j} \\
u^{(\ell)} &= \mathrm{WHT}_2^{-1}(\mathrm{Pad}_k(\widehat{v}^{(\ell)}))
\end{aligned}
\]

### 2.3 Forward Pass Pseudocode

```
Algorithm WHNO_Forward(a; W¹, b¹, W², b², Θ_dec):
  Input:   a ∈ ℝ^{h×w},  coefficient field
  Output:  u ∈ ℝ^{h×w},  predicted solution

  x₀ ← Concatenate[a, 1]                      # shape h×w×2
  ẋ₀ ← WHT₂(x₀)                               # h×w×2
  ẋ₀^k ← ẋ₀[0:k,0:k,:]
  ṽ₁ ← Zero(h,w,c)
  for i,j<k: for m in 1…c:
    ṽ₁[i,j,m] ← W¹[i,j] ⋅ ẋ₀^k[i,j,:] + b¹[i,j,m]
  v₁ ← WHT₂^{-1}(ṽ₁)
  x₁ ← v₁

  x₂ ← Conv1×1(Concatenate[x₁,a]; Θ_cond)
  ẋ₂ ← WHT₂(x₂)
  ẋ₂^k ← ẋ₂[0:k,0:k,:]
  ṽ₂ ← Zero(h,w,c)
  for i,j<k: for m in 1…c:
    ṽ₂[i,j,m] ← W²[i,j] ⋅ ẋ₂^k[i,j,:] + b²[i,j,m]
  v₂ ← WHT₂^{-1}(ṽ₂)
  x₃ ← v₂ + x₁

  u ← Decoder(Concatenate[x₃,a]; Θ_dec)
  return u
```

### 2.4 Parameterization

All learnable weights: $\{W^{(1)}, b^{(1)}, W^{(2)}, b^{(2)}, \text{input 1×1 conv}, \Theta_{\mathrm{dec}}\}$. Typical model: $876,\!241$ parameters ($73,\!728$ spectral, $802,\!513$ decoder).

## 3. Training Regimes and Experimental Setup

### 3.1 Loss and Optimization

Training minimizes mean squared error (MSE) across the spatial domain:

\[
\mathcal{L}_{\mathrm{MSE}} = \frac{1}{hw} \sum_{i,j} (u_{ij}^{\mathrm{pred}} - u_{ij}^{\mathrm{true}})^2
\]

Optimization: AdamW, learning rate $10^{-3}$ (cosine decay/step), weight decay $10^{-6}$, batch size 4 (heat, Darcy), 1–2 (Burgers); 400 epochs.

### 3.2 Data Generation for Discontinuous PDEs

- **Darcy flow**: Binary $\kappa(x) \in \{0,1\}$ with 4 random rectangles ($64 \times 64$). Solve $\nabla \cdot (\kappa \nabla p)=0$ with mixed Dirichlet/Neumann boundary conditions.
- **Heat conduction**: $k(x)$ matrix $=1.0$, inclusions $=5.0$ or $0.2$. $T(x,0)=1$ in central $32 \times 32$ region, Dirichlet $T=0$ on boundary, quasi-steady integration.
- **2D Burgers**: $\partial_t u + (u \cdot \nabla)u = \nu \nabla^2 u$, $\nu=10^{-3}$. Three $0.25\times0.25$ blocks with $u_\mathrm{block}$ at $t=0$, periodic boundary, $128\times128$, $600$ steps, $\Delta t=5 \times 10^{-4}$.

### 3.3 Spectral Truncation and Channelization

Typical spectral truncation: $k=16$ (i.e., $16 \times 16$ low-sequency block), 16 encoder channels, 64 decoder channels.

## 4. Empirical Evaluation and Benchmarks

### 4.1 Steady-State Darcy Flow

In binary permeability with four obstacles, WHNO achieves $0.88\%$ relative error in pressure $p$ on the $64 \times 64$ test set, with maximal errors localized at obstacle boundaries.

### 4.2 Heat Conduction with Discontinuous Conductivity

Under identical architectures and training, WHNO outperforms the Fourier Neural Operator (FNO) in all primary error metrics for heat conduction with discontinuous $k(x)$. Summary:

| Method   | MSE              | Mean Rel. Err. | Max Abs Error |
|----------|------------------|----------------|---------------|
| WHNO     | $1.13\times10^{-4}$ | $1.49\%$    | $0.153$       |
| FNO      | $1.48\times10^{-4}$ | $2.40\%$    | $0.192$       |
| Advantage| $24\%$ lower     | $38\%$ lower  | $20\%$ lower  |

Weighted ensemble ($w^*=0.50$) combining WHNO and FNO further reduces MSE by $35\%$ and max error by $8\%$.

### 4.3 2D Burgers Equation with Discontinuous Initial Conditions

For Burgers’ equation ($128\times128$), WHNO demonstrates $24\%$ lower MSE and $15\%$ lower mean absolute error versus FNO. Ensemble with $w^*=0.60$ realizes $35\%$ MSE and $20\%$ MAE reduction:

| Method     | MSE                | MAE                | Max Error       |
|------------|--------------------|--------------------|-----------------|
| WHNO       | $(1.13\pm0.49)\times10^{-4}$ | $(6.75\pm1.58)\times10^{-3}$ | $0.101\pm0.039$ |
| FNO        | $(1.48\pm0.92)\times10^{-4}$ | $(7.93\pm2.49)\times10^{-3}$ | $0.104\pm0.034$ |
| Ensemble   | $(0.73\pm0.37)\times10^{-4}$ | $(5.39\pm1.43)\times10^{-3}$ | $0.093\pm0.037$ |

Across all tasks, the WHNO+FNO ensemble consistently achieves $\sim35\%$ lower MSE relative to WHNO alone (up to $50\%$ over FNO), and reduces error variance [2511.07347].

## 5. Discussion and Design Rationale

### 5.1 Mitigating the Gibbs Phenomenon

The rectangular Walsh basis inherently represents step-like or piecewise-constant functions exactly, precluding the overshoot or ringing that afflicts Fourier (oscillatory) bases near discontinuities. For a field with explicit jump discontinuities, the Walsh spectrum is sparse; low-sequency truncation preserves interface sharpness, unlike Fourier truncation which requires many retained modes.

### 5.2 Representation Complementarity

WHNO captures discontinuities and sharp interfaces, while FNO is optimal for smooth oscillatory or gradient-dominated fields. In many physical PDEs, both features coexist—the ensemble leverages the strengths of each: WHNO dominates near interfaces, FNO in smooth interiors. The optimal ensemble weight depends on the proportion of discontinuous versus smooth features (e.g., $w^*=0.5$ for heat conduction, $w^*=0.6$ for Burgers).

### 5.3 Computational Trade-offs

Both WHNO and FNO have $O(n\log n)$ spectral layer complexity. While an ensemble doubles inference time, no extra training is required and the $\sim35\%$ error reduction may be warranted in applications with critical requirements for interface resolution (e.g., composite material design, subsurface flow in fractured media).

### 5.4 Recommended Usage Patterns

- Use **WHNO** alone when discontinuities predominate and inference speed is a constraint.
- Use **WHNO+FNO ensemble** for maximal accuracy and broad robustness across discontinuous and smooth regions.
- Use **FNO** alone for strongly smooth (e.g., Gaussian random field) coefficients or when discontinuities are absent.

## 6. Summary

The Walsh-Hadamard Neural Operator is a spectral neural operator targeting PDEs with discontinuous coefficients or sharp local features. Its rectangular wave basis and low-sequency spectral weights enable efficient, direct learning of sharp interfaces, eliminating Fourier-induced artifacts. For heterogeneous PDEs, ensembling WHNO with FNO exploits complementary basis properties, delivering state-of-the-art accuracy and robustness with moderate computational overhead [2511.07347].

Source: https://www.emergentmind.com/topics/walsh-hadamard-neural-operators-whno