arXiv:2610.08592cs.LGOct 2026

Manuscript Offprint

arXiv:2610.08592

CNet: A Complex-Valued Deep Learning Framework with Wirtinger Autodifferentiation and FFT--Hadamard Convolution

Marcel Crasmaru

Abstract

CNet is a C++/CUDA framework for building and researching deep complex-valued neural networks (CVNNs), and for optimizing complex-valued functions by gradient descent with Wirtinger derivatives. Complex-valued models are comparatively underexplored, yet they are a natural fit for domains where data is intrinsically complex—radio-frequency (IQ) communications, MRI k-space, radar/SAR, and audio spectra—and where phase carries information that magnitude-only real networks discard. CNet takes a physics-native stance: a network is a cascade of complex—and often unitary (the DFT)—operations acting on an amplitude vector, and classification is a Born-rule measurement pk=∣zk∣2/∥z∥2p_k = |z_k|^2 / \|z\|^2 rather than a softmax over real logits.

This paper documents the framework’s design—a depth-ordered computation graph that is cloned onto the GPU for batched execution—and its library of complex layers. Beyond the original layers it adds a family of signal-processing primitives that make the identity conv(x, k) = IFFT(FFT(x) ⊙ FFT(k)) usable as a learnable convolutional network: local-kernel construction by spectral padding (Pad), the inverse DFT (InverseFourierTrans), a phase-invariant magnitude nonlinearity (CModulus2, ∣z∣2|z|^2), holomorphic powers (CPower, zMz^M), and mean pooling over time (MeanPool). It also adds GPU implementations of these layers, a true-Adam optimizer on the GPU, and a forward-only inference mode with a reduced memory footprint.

Note. Alongside the framework we present three studies. (1) A fully complex-valued FNet-style causal sequence model, built on a new O(Nlog⁡N)O(N \log N) causal Fourier mixer (Section 6): properly tuned, it matches or exceeds a parameter-matched real-valued causal FNet on character-level tiny-shakespeare, reaching the real model's converged quality in under half the training steps. (2,3) Two architectural bottleneck analyses—radio-modulation classification on RML2016.10a [4] and the Fourier phase problem of coherent-diffraction imaging / crystallography—that isolate exactly where complex-valued networks still need new operators (a temporal-structure feature map and a route through measurement non-uniqueness, respectively). Across all three the complex machinery provably learns the physically correct structure (Section 11); the remaining open problems are concrete and operator-level (Section 12).

1 Motivation and Design Philosophy

PyTorch and JAX both support complex tensors and complex-aware autodiff, and for mainstream work they are the right tools—far more mature, faster at scale, multi-GPU, and backed by large ecosystems. CNet does not compete on that axis. It exists because, for research on complex-valued networks specifically, a complex-first, transparent substrate has concrete advantages.

• Complex is the default, not a bolted-on dtype. In the mainstream frameworks complex coverage is uneven: many layers, normalizations, activations, initializers, and optimizers assume real tensors, so a CVNN is assembled from real building blocks plus hand-written patches whose gradient conventions must be checked case by case. In CNet every variable, layer, loss, and the optimizer are complex by construction.

• Wirtinger gradients are explicit, first-class objects. Each layer manipulates the pair (∂L/∂z,∂L/∂zˉ)(\partial L/\partial z, \partial L/\partial \bar{z}) directly, and the non-holomorphic case (e.g. ∣z∣2|z|^2) is handled in the open rather than hidden behind a conjugation convention [2]. Every layer ships a CPU reference and a GPU kernel checked against each other and against finite differences, so the complex gradient is auditable, not trusted.

• Spectral structure is built in. The DFT, the Hadamard (spectral) product, the inverse DFT, and the conv = IFFT(FFT · FFT) equivalence are first-class layers. Problems whose natural domain is the frequency plane map onto the framework directly.

• A physics-native model and loss—the Born rule. This is the sharpest departure from the mainstream frameworks. CNet reads a network’s output as a complex amplitude vector z—a state—and defines the class probabilities by the quantum-measurement (Born) rule

pk=∣zk∣2∥z∥2,L(z,y)=−∑kyklog⁡zkzk⋆∥z∥2.(1)p_{k}=\frac{|z_{k}|^{2}}{\|z\|^{2}},\qquad\mathcal{L}(z,y)=-\sum_{k}y_{k}\log\frac{z_{k}z_{k}^{\star}}{\|z\|^{2}}. \tag{1}

Classification is a measurement on an amplitude produced by a cascade of complex—often unitary—operations, rather than real logits passed through a softmax. This inductive bias is natural for physical and wave/field data: an IQ baseband sample is the complex envelope of a real passband signal, an MRI k-space sample is a complex Fourier coefficient, and a wavefunction is a complex amplitude. PyTorch and JAX provide no such head or loss out of the box.

• A small, auditable substrate. The full forward/backward of every layer and its CUDA kernel is explicit and readable, and the GPU execution model (a depth-ordered graph cloned across the batch) is visible and controllable.

In short: use PyTorch or JAX to ship; use CNet to study complex-valued learning itself—to model data in its native complex/amplitude form with a Born-rule measurement head, to prototype operators whose complex gradients you need to see and control, and to work natively in the spectral domain. The trade-offs (single-GPU, Linux/macOS, a smaller op set) are listed in Section 12.1.

A note on why C≠R2\mathbb{C} \neq \mathbb{R}^2: although C≅R2\mathbb{C} \cong \mathbb{R}^2 as a vector space, the field multiplication couples the two components, so a holomorphic complex layer is not an unconstrained R2→R2\mathbb{R}^2 \to \mathbb{R}^2 map. CNet carries this structure end to end via the Wirtinger pair (∂/∂z,∂/∂zˉ)(\partial/\partial z, \partial/\partial \bar{z}).