|q⟩ Bad Qubits

advanced · Programming · Quantum Machine Learning (Advanced)

Data Re-Uploading

A single layer of angle encoding loads each feature once, and a one-qubit model so built can only represent very simple functions. Data re-uploading breaks that ceiling: it interleaves the data encoding with trainable rotations repeatedly, so even one qubit becomes a universal function approximator (Pérez-Salinas et al., 2020).

The idea

Instead of encode-once-then-train, alternate the two:

ψ(x,θ)=[=1LW(θ)S(x)]0,|\psi(x,\boldsymbol{\theta})\rangle = \Bigl[\prod_{\ell=1}^{L} W(\boldsymbol{\theta}_\ell)\,S(x)\Bigr]|0\rangle,

where S(x)S(x) is the data-encoding block (a Pauli rotation such as RY(x)R_Y(x)) and each W(θ)W(\boldsymbol{\theta}_\ell) is an independent trainable block. The same feature xx is fed in LL times, once per layer. The repetition is what buys expressivity.

Why repetition helps: the Fourier view

Schuld, Sweke, and Meyer (2021) gave the clean explanation. A variational model with data entered through Pauli rotations computes a truncated Fourier series in the input:

f(x)=ωΩcωeiωx.f(x) = \sum_{\omega \in \Omega} c_\omega\, e^{i\omega x}.

The frequencies Ω\Omega that the model can access are fixed by how many times and how the data is encoded — not by the trainable weights. Encoding xx only once gives a single nonzero frequency, so the model is essentially a sinusoid. Re-uploading LL times enlarges the accessible frequency spectrum, letting the trainable coefficients cωc_\omega build richer functions. The trainable layers set the coefficients; the encoding repetition sets the frequencies.

A two-layer single-qubit model

Take the encoding generator to be RY(x)R_Y(x) and a trainable RZ(θ)R_Z(\theta_\ell) per layer. Two layers give

ψ=RZ(θ2)RY(x)RZ(θ1)RY(x)0,|\psi\rangle = R_Z(\theta_2)\,R_Y(x)\,R_Z(\theta_1)\,R_Y(x)\,|0\rangle,

with the same xx uploaded in both RYR_Y blocks. The two distinct trainable angles θ1,θ2\theta_1, \theta_2 act between and after the uploads. Already this reaches a two-frequency Fourier model — far beyond what a single upload can express.

Try it

Build the two-layer re-uploading state for input x=0.7x = 0.7 with trained angles θ1=0.4\theta_1 = 0.4 and θ2=1.1\theta_2 = 1.1. Apply gates so the circuit realizes

RZ(θ2)RY(x)RZ(θ1)RY(x)0,R_Z(\theta_2)\,R_Y(x)\,R_Z(\theta_1)\,R_Y(x)\,|0\rangle,

i.e. (in call order) RY(x)R_Y(x), RZ(θ1)R_Z(\theta_1), RY(x)R_Y(x), RZ(θ2)R_Z(\theta_2). The grader checks the state vector. Note the same xx appears in both RYR_Y gates — that repetition is the whole point.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.