QuantumCore

Lesson 53 · 120 min · advanced

Quantum Convolutional Neural Networks

Loading progress…

A quantum convolutional neural network (QCNN) processes an nn-qubit state the way a convolutional network processes an image. Convolution layers apply one shared two-qubit unitary to all neighbouring pairs. Pooling layers measure half of the qubits and rotate their neighbours conditioned on the outcomes. This halves the number of qubits, and after log⁡2n\log_2n levels a single qubit is read out. The lesson proves, with the deferred-measurement principle and an explicit partial trace, that measurement-based pooling equals a controlled rotation followed by discarding the control. It then counts the 6log⁡2n6\log_2n shared parameters, relates the architecture to the MERA tensor network read in reverse and to renormalisation, and explains with a light-cone argument why QCNNs avoid barren plateaus (Pesah et al. 2021). Finally it writes the lab's four-qubit QCNN out gate by gate and derives its parameter-shift gradients.

Prerequisites: Strongly Entangling Layers, The Parameter-Shift Rule, Partial Trace & Reduced States

Objectives and key results
  • Build a QCNN from translation-invariant convolution layers, measurement-based pooling layers and a final readout, and state the symmetry of a brick-wall layer with shared weights.

  • Prove that measuring a qubit and applying a conditioned rotation to its neighbour gives the same reduced state as a controlled rotation followed by the partial trace over the control.

  • Derive the shared-weight parameter count P(n)=6log⁡2nP(n)=6\log_2n and compare it with the 10n−1410n-14 parameters of the same network without weight sharing.

  • Explain the QCNN as a MERA read in reverse, i.e. a sequence of coarse-graining channels, and state the trainability result Var[∂C]∈Ω(1/poly(n))\mathrm{Var}[\partial C]\in\Omega(1/\mathrm{poly}(n)) with its light-cone intuition.

  • Write the lab's 4-qubit QCNN gate by gate, compute its output for zero weights, and derive which parameter-shift rules give exact gradients for its shared and controlled weights.

theorem · Pooling by deferred measurement
U=∑m∈{0,1}∣m⟩⟨m∣c⊗Vm:Trc[UρU†]=∑mVm ρmm Vm†,ρmm=(⟨m∣c⊗I) ρ (∣m⟩c⊗I)U=\sum_{m\in\{0,1\}}\lvert m\rangle\langle m\rvert_c\otimes V_m:\qquad\mathrm{Tr}_c\big[U\rho U^\dagger\big]=\sum_{m}V_m\,\rho_{mm}\,V_m^\dagger,\quad\rho_{mm}=(\langle m\rvert_c\otimes I)\,\rho\,(\lvert m\rangle_c\otimes I)
formula · Parameter count
Pshared(n)=∑ℓ=1log⁡2n(4+2)=6log⁡2n,Punshared(n)=5∑ℓ=1log⁡2n−1n2ℓ−1+6=10n−14P_{\text{shared}}(n)=\sum_{\ell=1}^{\log_2n}(4+2)=6\log_2n,\qquad P_{\text{unshared}}(n)=5\sum_{\ell=1}^{\log_2n-1}\frac{n}{2^{\ell-1}}+6=10n-14
identity · Zero-weight output of the lab QCNN
fp=0(x)=⟨Z1Z3⟩E(x)∣0000⟩=cos⁡(πx1)cos⁡(πx3)f_{p=0}(x)=\langle Z_1Z_3\rangle_{E(x)\lvert0000\rangle}=\cos(\pi x_1)\cos(\pi x_3)
theorem · Absence of barren plateaus (Pesah et al. 2021)
Var[∂θμC] ≥ F(n),F(n)∈Ω(1/poly(n))\mathrm{Var}\big[\partial_{\theta_\mu}C\big]\ \ge\ F(n),\qquad F(n)\in\Omega\big(1/\mathrm{poly}(n)\big)
formula · Shift rules for pooling weights
G=∣1⟩⟨1∣c⊗12P: spec⁡G={0,0,±12},f′=c+[f+π2−f−π2]−c−[f+3π2−f−3π2],c±=2±142G=\lvert1\rangle\langle1\rvert_c\otimes\tfrac12P:\ \operatorname{spec}G=\{0,0,\pm\tfrac12\},\qquad f'=c_+\big[f_{+\frac\pi2}-f_{-\frac\pi2}\big]-c_-\big[f_{+\frac{3\pi}2}-f_{-\frac{3\pi}2}\big],\quad c_\pm=\frac{\sqrt2\pm1}{4\sqrt2}

From convolutional networks to QCNNs#

A classical convolutional network rests on three ideas: locality (a filter sees a few neighbouring pixels), weight sharing (the same filter at every position) and pooling (neighbouring outputs are merged, so each layer works at a coarser scale). Cong, Choi and Lukin (2019) carried these ideas to circuits acting on an nn-qubit input state, such as an encoded image or the ground state of a spin chain. The resulting quantum convolutional neural network has depth and parameter count O(log⁡n)O(\log n), and its gradients do not vanish exponentially.

Definition

Quantum convolutional neural network

Let n=2Ln=2^L qubits carry an input state ρ0\rho_0, and let level ℓ=1,…,L\ell=1,\dots,L act on an ordered list of mℓ=n/2ℓ−1m_\ell=n/2^{\ell-1} active qubits (a0,…,amℓ−1)(a_0,\dots,a_{m_\ell-1}), starting with all nn qubits. Each level consists of (i) a convolution layer: one two-qubit unitary UℓU_\ell on the even pairs (a2k,a2k+1)(a_{2k},a_{2k+1}), then on the odd pairs (a2k+1,a2k+2 mod mℓ)(a_{2k+1},a_{2k+2\bmod m_\ell}) (a single pair when mℓ=2m_\ell=2); (ii) a pooling layer: each c=a2kc=a_{2k} is measured, its neighbour t=a2k+1t=a_{2k+1} is rotated by Vm(ℓ)V^{(\ell)}_m on outcome mm, and cc is discarded. After level LL one qubit is left; the output is f=Tr[Z ρL]f=\mathrm{Tr}\big[Z\,\rho_L\big] and the predicted class sign f\mathrm{sign}\,f. Cong et al. also insert a fully connected layer, a general unitary on the last few qubits; in the lab's model the final convolution C13C_{13} on both remaining qubits plays this role.

The diagram shows the lab's model. Gates with the same colour share weights: the four first-layer convolution blocks use p0,…,p3p_0,\dots,p_3, the two first-layer pooling blocks p4,p5p_4,p_5. Pooled qubits are greyed out, and the Bloch vectors show the reduced states of the active qubits. Weight sharing is a symmetry statement:

Derivation

A shared brick-wall layer commutes with translation by two sites

  1. Step 1:
    T∣q0q1⋯qm−1⟩=∣qm−2qm−1q0⋯qm−3⟩,T W(i,j) T†=W(i+2, j+2)T\lvert q_0q_1\cdots q_{m-1}\rangle=\lvert q_{m-2}q_{m-1}q_0\cdots q_{m-3}\rangle,\qquad T\,W_{(i,j)}\,T^\dagger=W_{(i+2,\,j+2)}
    TT is the cyclic shift by two sites on the ring of active qubits (indices mod mm), a permutation unitary. Conjugating a two-qubit gate on (i,j)(i,j) by a permutation moves it to the permuted qubits.
  2. Step 2:
    E=∏k=0m/2−1U(2k, 2k+1),O=∏k=0m/2−1U(2k+1, 2k+2)E=\prod_{k=0}^{m/2-1}U_{(2k,\,2k+1)},\qquad O=\prod_{k=0}^{m/2-1}U_{(2k+1,\,2k+2)}
    The even and odd sublayers of one convolution layer, all with the same UU. Inside a sublayer the pairs are disjoint, so the factors commute and their order is irrelevant.
  3. Step 3:
    TET†=∏kU(2k+2, 2k+3)=E,TOT†=∏kU(2k+3, 2k+4)=OTET^\dagger=\prod_kU_{(2k+2,\,2k+3)}=E,\qquad TOT^\dagger=\prod_kU_{(2k+3,\,2k+4)}=O
    Shifting by two maps the set of even pairs onto itself and the set of odd pairs onto itself (indices mod mm). Because the weights are shared, every shifted factor is again a factor of the same product.
  4. Step 4:
    T (OE) T†=(TOT†)(TET†)=OET\,(OE)\,T^\dagger=(TOT^\dagger)(TET^\dagger)=OE
    Insert T†T=IT^\dagger T=I between the two sublayers. The whole convolution layer commutes with TT, and so does a pooling layer on the pairs (2k,2k+1)(2k,2k+1), by the same argument.
  5. Step 5:
    T1 E T1†=∏kU(2k+1, 2k+2)=O≠E in generalT_1\,E\,T_1^\dagger=\prod_kU_{(2k+1,\,2k+2)}=O\ne E\ \text{in general}
    A one-site shift exchanges the sublayers: the layer is translation invariant with a two-site unit cell, like a convolution with stride 22.

Result

[ T, O E ]=0for every shared two-qubit block U\boxed{[\,T,\ O\,E\,]=0\quad\text{for every shared two-qubit block }U}

Pooling: measurement, conditioned rotation, partial trace#

Pooling measures a qubit cc and uses the outcome to rotate a neighbour tt. Hardware with mid-circuit measurement and feed-forward can do this literally; a simulator can instead apply a controlled rotation and never look at cc again. The deferred-measurement principle from the teleportation lesson says the two agree. We need the precise statement for an arbitrary entangled, mixed input with cc discarded afterwards; the tools are the block decomposition of a density matrix and the partial trace.

Theorem

Measurement-based pooling equals a controlled rotation followed by the partial trace

Let ρ\rho be a density operator on qubits cc and tt (and possibly further qubits EE, on which everything below acts as the identity), and let V0,V1V_0,V_1 be unitaries on tt. Write ρjk=(⟨j∣c⊗I) ρ (∣k⟩c⊗I)\rho_{jk}=(\langle j\rvert_c\otimes I)\,\rho\,(\lvert k\rangle_c\otimes I) for the 2×22\times2 blocks. Procedure M: measure cc in the computational basis, apply VmV_m to tt on outcome mm, discard cc, and forget mm. Procedure D: apply U=∣0⟩⟨0∣c⊗V0+∣1⟩⟨1∣c⊗V1U=\lvert0\rangle\langle0\rvert_c\otimes V_0+\lvert1\rangle\langle1\rvert_c\otimes V_1 and trace out cc. Both procedures produce the state σt=V0 ρ00 V0†+V1 ρ11 V1†,\sigma_t=V_0\,\rho_{00}\,V_0^\dagger+V_1\,\rho_{11}\,V_1^\dagger, and measuring cc after UU reproduces the outcome probabilities pm=Tr ρmmp_m=\mathrm{Tr}\,\rho_{mm} and the conditional states of procedure M. The lab's pooling uses V0=RX(b1)V_0=R_X(b_1) and V1=RZ(b0)V_1=R_Z(b_0).

Proof (10 steps)
  1. Step 1:
    ρ=∑j,k∈{0,1}∣j⟩⟨k∣c⊗ρjk=(ρ00ρ01ρ10ρ11),ρ10=ρ01†\rho=\sum_{j,k\in\{0,1\}}\lvert j\rangle\langle k\rvert_c\otimes\rho_{jk}=\begin{pmatrix}\rho_{00}&\rho_{01}\\\rho_{10}&\rho_{11}\end{pmatrix},\qquad\rho_{10}=\rho_{01}^\dagger
    Insert I=∣0⟩⟨0∣+∣1⟩⟨1∣I=\lvert0\rangle\langle0\rvert+\lvert1\rangle\langle1\rvert on both sides of ρ\rho on qubit cc. With cc the more significant qubit, this is the 4×44\times4 matrix cut into 2×22\times2 blocks; hermiticity of ρ\rho gives ρ10=ρ01†\rho_{10}=\rho_{01}^\dagger.
  2. Step 2:
    U=(V000V1),U†=(V0†00V1†)U=\begin{pmatrix}V_0&0\\0&V_1\end{pmatrix},\qquad U^\dagger=\begin{pmatrix}V_0^\dagger&0\\0&V_1^\dagger\end{pmatrix}
    A controlled operation with the two branch unitaries V0V_0 and V1V_1 is block diagonal in the control basis.
  3. Step 3:
    UρU†=(V0ρ00V0†V0ρ01V1†V1ρ10V0†V1ρ11V1†)U\rho U^\dagger=\begin{pmatrix}V_0\rho_{00}V_0^\dagger&V_0\rho_{01}V_1^\dagger\\V_1\rho_{10}V_0^\dagger&V_1\rho_{11}V_1^\dagger\end{pmatrix}
    Block matrix multiplication: the (j,k)(j,k) block of UρU†U\rho U^\dagger is VjρjkVk†V_j\rho_{jk}V_k^\dagger.
  4. Step 4:
    Trc[M]=∑m(⟨m∣c⊗I) M (∣m⟩c⊗I)=M00+M11\mathrm{Tr}_c[M]=\sum_{m}(\langle m\rvert_c\otimes I)\,M\,(\lvert m\rangle_c\otimes I)=M_{00}+M_{11}
    Definition of the partial trace over cc from the partial-trace lesson: the sum of the diagonal blocks.
  5. Step 5:
    Trc[UρU†]=V0ρ00V0†+V1ρ11V1†\mathrm{Tr}_c\big[U\rho U^\dagger\big]=V_0\rho_{00}V_0^\dagger+V_1\rho_{11}V_1^\dagger
    Apply the previous line to the matrix of line three. The coherences V0ρ01V1†V_0\rho_{01}V_1^\dagger between the two control values sit in off-diagonal blocks and drop out.
  6. Step 6:
    Πm=∣m⟩⟨m∣c⊗I:pm=Tr[Πmρ]=Tr ρmm,ρ↦ΠmρΠmpm=∣m⟩⟨m∣c⊗ρmmpm\Pi_m=\lvert m\rangle\langle m\rvert_c\otimes I:\qquad p_m=\mathrm{Tr}\big[\Pi_m\rho\big]=\mathrm{Tr}\,\rho_{mm},\qquad\rho\mapsto\frac{\Pi_m\rho\Pi_m}{p_m}=\lvert m\rangle\langle m\rvert_c\otimes\frac{\rho_{mm}}{p_m}
    Born rule and Lüders update for the projective measurement of cc: Πm\Pi_m selects the (m,m)(m,m) block.
  7. Step 7:
    ∣m⟩⟨m∣c⊗VmρmmVm†pm → Trc  VmρmmVm†pm\lvert m\rangle\langle m\rvert_c\otimes\frac{V_m\rho_{mm}V_m^\dagger}{p_m}\ \xrightarrow{\ \mathrm{Tr}_c\ }\ \frac{V_m\rho_{mm}V_m^\dagger}{p_m}
    Procedure M on outcome mm: rotate tt by VmV_m, then discard cc. The trace of ∣m⟩⟨m∣\lvert m\rangle\langle m\rvert is 11.
  8. Step 8:
    ∑mpm VmρmmVm†pm=V0ρ00V0†+V1ρ11V1†=Trc[UρU†]\sum_mp_m\,\frac{V_m\rho_{mm}V_m^\dagger}{p_m}=V_0\rho_{00}V_0^\dagger+V_1\rho_{11}V_1^\dagger=\mathrm{Tr}_c\big[U\rho U^\dagger\big]
    Forgetting the outcome averages the conditional states with their probabilities (outcomes with pm=0p_m=0 contribute ρmm=0\rho_{mm}=0). The result is the state of line five.
  9. Step 9:
    Πm UρU† Πm=∣m⟩⟨m∣c⊗VmρmmVm†,Tr[ΠmUρU†]=Tr ρmm=pm\Pi_m\,U\rho U^\dagger\,\Pi_m=\lvert m\rangle\langle m\rvert_c\otimes V_m\rho_{mm}V_m^\dagger,\qquad\mathrm{Tr}\big[\Pi_mU\rho U^\dagger\big]=\mathrm{Tr}\,\rho_{mm}=p_m
    Measuring cc after UU gives the same probabilities, because VmV_m is unitary, and the same conditional states. This is the deferred-measurement principle: the measurement commutes with gates that use cc only as a control.
  10. Step 10:
    Vm → Vm⊗IE:Trc[UρU†]=∑m(Vm⊗IE) ρmm (Vm⊗IE)†V_m\ \to\ V_m\otimes I_E:\qquad\mathrm{Tr}_c\big[U\rho U^\dagger\big]=\sum_m(V_m\otimes I_E)\,\rho_{mm}\,(V_m\otimes I_E)^\dagger
    With further qubits EE the blocks ρjk\rho_{jk} act on t⊗Et\otimes E and every step holds verbatim, as needed inside a QCNN.

∎

Derivation

The lab pooling block as a controlled pair of rotations

  1. Step 1:
    Pc→t(b0,b1)=Xc⋅CRX(c,t,b1)⋅Xc⋅CRZ(c,t,b0)P_{c\to t}(b_0,b_1)=X_c\cdot CR_X(c,t,b_1)\cdot X_c\cdot CR_Z(c,t,b_0)
    The time-ordered gates CRZ(c,t,b0)CR_Z(c,t,b_0), X(c)X(c), CRX(c,t,b1)CR_X(c,t,b_1), X(c)X(c) written as one matrix product, last gate leftmost.
  2. Step 2:
    Xc(∣0⟩⟨0∣⊗I+∣1⟩⟨1∣⊗RX(b1))Xc=∣1⟩⟨1∣⊗I+∣0⟩⟨0∣⊗RX(b1)X_c\big(\lvert0\rangle\langle0\rvert\otimes I+\lvert1\rangle\langle1\rvert\otimes R_X(b_1)\big)X_c=\lvert1\rangle\langle1\rvert\otimes I+\lvert0\rangle\langle0\rvert\otimes R_X(b_1)
    X∣0⟩⟨0∣X=∣1⟩⟨1∣X\lvert0\rangle\langle0\rvert X=\lvert1\rangle\langle1\rvert and X∣1⟩⟨1∣X=∣0⟩⟨0∣X\lvert1\rangle\langle1\rvert X=\lvert0\rangle\langle0\rvert: sandwiching between two XX gates makes the rotation fire on control value 00.
  3. Step 3:
    (∣0⟩⟨0∣⊗RX(b1)+∣1⟩⟨1∣⊗I)(∣0⟩⟨0∣⊗I+∣1⟩⟨1∣⊗RZ(b0))=∣0⟩⟨0∣⊗RX(b1)+∣1⟩⟨1∣⊗RZ(b0)\big(\lvert0\rangle\langle0\rvert\otimes R_X(b_1)+\lvert1\rangle\langle1\rvert\otimes I\big)\big(\lvert0\rangle\langle0\rvert\otimes I+\lvert1\rangle\langle1\rvert\otimes R_Z(b_0)\big)=\lvert0\rangle\langle0\rvert\otimes R_X(b_1)+\lvert1\rangle\langle1\rvert\otimes R_Z(b_0)
    Multiply out; the cross terms contain ∣0⟩⟨0∣1⟩⟨1∣=0\lvert0\rangle\langle0\vert1\rangle\langle1\rvert=0.
  4. Step 4:
    Pc→t(b0,b1)=(cos⁡b12−isin⁡b1200−isin⁡b12cos⁡b120000e−ib0/20000eib0/2)P_{c\to t}(b_0,b_1)=\begin{pmatrix}\cos\frac{b_1}2&-i\sin\frac{b_1}2&0&0\\-i\sin\frac{b_1}2&\cos\frac{b_1}2&0&0\\0&0&e^{-ib_0/2}&0\\0&0&0&e^{ib_0/2}\end{pmatrix}
    The explicit 4×44\times4 matrix in the basis ∣c t⟩=∣00⟩,∣01⟩,∣10⟩,∣11⟩\lvert c\,t\rangle=\lvert00\rangle,\lvert01\rangle,\lvert10\rangle,\lvert11\rangle, using RX(b)=cos⁡b2I−isin⁡b2XR_X(b)=\cos\frac b2I-i\sin\frac b2X and RZ(b)=diag(e−ib/2,eib/2)R_Z(b)=\mathrm{diag}(e^{-ib/2},e^{ib/2}).
  5. Step 5:
    V0=RX(b1),V1=RZ(b0)V_0=R_X(b_1),\qquad V_1=R_Z(b_0)
    The form U=∑m∣m⟩⟨m∣⊗VmU=\sum_m\lvert m\rangle\langle m\rvert\otimes V_m of the theorem: once cc is ignored, the gates implement "measure cc; if 11 apply RZ(b0)R_Z(b_0) to tt, if 00 apply RX(b1)R_X(b_1)".
Derivation

Pooling as a channel and its Heisenberg dual

  1. Step 1:
    Φ(ρ)=Trc[UρU†]=∑mKm ρ Km†,Km=⟨m∣c⊗Vm\Phi(\rho)=\mathrm{Tr}_c\big[U\rho U^\dagger\big]=\sum_mK_m\,\rho\,K_m^\dagger,\qquad K_m=\langle m\rvert_c\otimes V_m
    Rewrite the pooled state of the theorem with the operators Km:C2⊗C2→C2K_m:\mathbb C^2\otimes\mathbb C^2\to\mathbb C^2, Km∣j⟩∣ϕ⟩=δmjVm∣ϕ⟩K_m\lvert j\rangle\lvert\phi\rangle=\delta_{mj}V_m\lvert\phi\rangle.
  2. Step 2:
    ∑mKm†Km=∑m∣m⟩⟨m∣⊗Vm†Vm=I4\sum_mK_m^\dagger K_m=\sum_m\lvert m\rangle\langle m\rvert\otimes V_m^\dagger V_m=I_4
    Completeness of the Kraus operators: Φ\Phi is trace preserving, and a map of Kraus form is completely positive. Pooling is a quantum channel from two qubits to one.
  3. Step 3:
    Tr[O Φ(ρ)]=Tr[Φ∗(O) ρ],Φ∗(O)=∑mKm†OKm=∑m∣m⟩⟨m∣c⊗Vm†OVm\mathrm{Tr}\big[O\,\Phi(\rho)\big]=\mathrm{Tr}\big[\Phi^*(O)\,\rho\big],\qquad\Phi^*(O)=\sum_mK_m^\dagger OK_m=\sum_m\lvert m\rangle\langle m\rvert_c\otimes V_m^\dagger OV_m
    Cyclicity of the trace defines the dual (Heisenberg-picture) map, which pulls an observable on tt back to an observable on c⊗tc\otimes t.
  4. Step 4:
    RX(b)†ZRX(b)=cos⁡b Z+sin⁡b Y,RZ(b)†ZRZ(b)=ZR_X(b)^\dagger ZR_X(b)=\cos b\,Z+\sin b\,Y,\qquad R_Z(b)^\dagger ZR_Z(b)=Z
    With RX(b)=cos⁡b2I−isin⁡b2XR_X(b)=\cos\frac b2I-i\sin\frac b2X: (cos⁡b2+isin⁡b2X)Z(cos⁡b2−isin⁡b2X)=(cos⁡2b2−sin⁡2b2)Z+2sin⁡b2cos⁡b2 Y(\cos\frac b2+i\sin\frac b2X)Z(\cos\frac b2-i\sin\frac b2X)=(\cos^2\frac b2-\sin^2\frac b2)Z+2\sin\frac b2\cos\frac b2\,Y, using XZX=−ZXZX=-Z and ZX=iYZX=iY. RZR_Z commutes with ZZ.
  5. Step 5:
    Φ∗(Zt)=∣0⟩⟨0∣c⊗(cos⁡b1 Z+sin⁡b1 Y)+∣1⟩⟨1∣c⊗Z\Phi^*(Z_t)=\lvert0\rangle\langle0\rvert_c\otimes\big(\cos b_1\,Z+\sin b_1\,Y\big)+\lvert1\rangle\langle1\rvert_c\otimes Z
    Insert V0=RX(b1)V_0=R_X(b_1) and V1=RZ(b0)V_1=R_Z(b_0). The angle b0b_0 has dropped out.
  6. Step 6:
    f=Tr[Z3 Φ1→3(ρ)] ⇒ ∂f∂p10≡0f=\mathrm{Tr}\big[Z_3\,\Phi_{1\to3}(\rho)\big]\ \Rightarrow\ \frac{\partial f}{\partial p_{10}}\equiv0
    In the lab, the last pooling P1→3(p10,p11)P_{1\to3}(p_{10},p_{11}) is followed directly by the measurement of Z3Z_3, so the output does not depend on p10p_{10} at all. Only 1111 of the 1212 weights matter. A ZZ rotation conditioned on the control is invisible to a ZZ measurement.

Quick check

Before a pooling block Pc→t(b0,b1)P_{c\to t}(b_0,b_1) the pair is in the Bell state 12(∣00⟩+∣11⟩)\frac1{\sqrt2}\big(\lvert00\rangle+\lvert11\rangle\big) (order c tc\,t). With b0=b1=πb_0=b_1=\pi, what is ⟨Zt⟩\langle Z_t\rangle after pooling?

tolerance ±0.000001

After the first pooling layer, qubits 00 and 22 are greyed out: by the theorem they may simply be traced out. The Bloch vectors of qubits 11 and 33 are the reduced states σt\sigma_t, generally mixed (shorter than 11) because the pooled qubits were entangled with them.

Logarithmically many parameters#

Proposition

Parameter count with and without weight sharing

Let n=2L≥4n=2^L\ge4. In a QCNN whose convolution block has 44 parameters and whose pooling block has 22, sharing one convolution block and one pooling block per level gives P(n)=6log⁡2nP(n)=6\log_2n parameters, e.g. P(4)=12P(4)=12 (the lab), P(8)=18P(8)=18, P(16)=24P(16)=24. Giving every block its own parameters gives Pun(n)=10n−14∈Θ(n)P_{\mathrm{un}}(n)=10n-14\in\Theta(n), e.g. Pun(4)=26P_{\mathrm{un}}(4)=26 and Pun(8)=66P_{\mathrm{un}}(8)=66. In both cases the circuit has Θ(n)\Theta(n) gates and depth at most 1+12log⁡2n1+12\log_2n.

Proof (6 steps)
  1. Step 1:
    m1=n,mℓ+1=mℓ2 ⇒ mℓ=n2ℓ−1,mL=2  for L=log⁡2nm_1=n,\qquad m_{\ell+1}=\frac{m_\ell}2\ \Rightarrow\ m_\ell=\frac{n}{2^{\ell-1}},\qquad m_L=2\ \text{ for }L=\log_2n
    Each pooling layer discards one qubit of every pair, so the number of active qubits halves. Level LL starts with two qubits and ends with one.
  2. Step 2:
    P(n)=∑ℓ=1L(4+2)=6L=6log⁡2nP(n)=\sum_{\ell=1}^{L}(4+2)=6L=6\log_2n
    With sharing, each level contributes one convolution block (44 weights) and one pooling block (22 weights), however many qubits it acts on.
  3. Step 3:
    mℓ≥4:4 mℓ⏟conv: mℓ pairs+2⋅mℓ2⏟pool: mℓ/2 pairs=5mℓ;mL=2:4+2=6m_\ell\ge4:\quad\underbrace{4\,m_\ell}_{\text{conv: }m_\ell\text{ pairs}}+\underbrace{2\cdot\tfrac{m_\ell}2}_{\text{pool: }m_\ell/2\text{ pairs}}=5m_\ell;\qquad m_L=2:\quad4+2=6
    Without sharing, the ring of mℓm_\ell qubits has mℓ/2m_\ell/2 even and mℓ/2m_\ell/2 odd pairs, each with its own 44 weights, and mℓ/2m_\ell/2 pooling pairs with 22 weights each. The last level has one pair of each kind.
  4. Step 4:
    ∑ℓ=1L−1n2ℓ−1=n 1−2−(L−1)1−12=2n−2n2L−1=2n−4\sum_{\ell=1}^{L-1}\frac{n}{2^{\ell-1}}=n\,\frac{1-2^{-(L-1)}}{1-\frac12}=2n-\frac{2n}{2^{L-1}}=2n-4
    Geometric sum with ratio 12\tfrac12 and L−1L-1 terms; 2L−1=n/22^{L-1}=n/2.
  5. Step 5:
    Pun(n)=5(2n−4)+6=10n−14P_{\mathrm{un}}(n)=5(2n-4)+6=10n-14
    Add the two contributions. For n=4n=4: 5⋅4+6=265\cdot4+6=26; for n=8n=8: 5(8+4)+6=665(8+4)+6=66.
  6. Step 6:
    #blocks=∑ℓ=1L−132mℓ+2=3n−4,depth≤1+∑ℓ=1L(4+4+4)=1+12log⁡2n\#\text{blocks}=\sum_{\ell=1}^{L-1}\tfrac32m_\ell+2=3n-4,\qquad\text{depth}\le1+\sum_{\ell=1}^{L}(4+4+4)=1+12\log_2n
    The block count is the same geometric sum. One encoding layer, two convolution sublayers of depth 44 (RYR_Y, CNOT, RYR_Y, CNOT) and a pooling layer of depth 44 per level bound the depth; for n=4n=4 the gate count is 4+6⋅5+4⋅3=464+6\cdot5+4\cdot3=46.

∎

Sharing builds translation invariance into the model and reduces the number of training examples it needs. The eight-qubit structure has three levels with eight, four and one convolution blocks, but only 6⋅3=186\cdot3=18 distinct weights.

Quick check

How many trainable parameters does the shared-weight QCNN of this lesson have on n=16n=16 qubits?

tolerance ±0.5

QCNNs as MERA read in reverse#

The multiscale entanglement renormalisation ansatz (MERA, Vidal 2008) is a tensor network for ground states of critical spin chains. Read from the top, it is a circuit that repeatedly doubles the number of qubits with isometries ww (a fresh qubit in ∣0⟩\lvert0\rangle entangled with an existing one) and disentanglers uu (two-qubit unitaries on neighbouring pairs). A QCNN has the shape of a MERA read from the bottom.

Derivation

From MERA to coarse-graining channels

  1. Step 1:
    ∣Ψℓ−1⟩=Dℓ Wℓ ∣Ψℓ⟩,Wℓ=⨂w,w∣ϕ⟩=uw(∣0⟩⊗∣ϕ⟩),w†w=I\lvert\Psi_{\ell-1}\rangle=D_\ell\,W_\ell\,\lvert\Psi_\ell\rangle,\qquad W_\ell=\bigotimes w,\quad w\lvert\phi\rangle=u_w\big(\lvert0\rangle\otimes\lvert\phi\rangle\big),\quad w^\dagger w=I
    One MERA layer maps a state on m/2m/2 sites to a state on mm sites. Each isometry is a unitary uwu_w acting on an ancilla in ∣0⟩\lvert0\rangle and an existing qubit, and DℓD_\ell is a brick-wall layer of disentanglers.
  2. Step 2:
    Wℓ†Dℓ†∣Ψℓ−1⟩=∣Ψℓ⟩W_\ell^\dagger D_\ell^\dagger\lvert\Psi_{\ell-1}\rangle=\lvert\Psi_\ell\rangle
    DℓD_\ell is unitary and Wℓ†Wℓ=IW_\ell^\dagger W_\ell=I. Read in reverse, a layer first applies the unitaries Dℓ†D_\ell^\dagger on neighbouring pairs, which is a convolution layer, and then uw†u_w^\dagger on each pair. For states in the MERA's image the ancilla returns exactly to ∣0⟩\lvert0\rangle.
  3. Step 3:
    Φℓ(ρ)=Tranc[(⨂uw†)Dℓ† ρ Dℓ(⨂uw)]\Phi_\ell(\rho)=\mathrm{Tr}_{\text{anc}}\Big[\big(\textstyle\bigotimes u_w^\dagger\big)D_\ell^\dagger\,\rho\,D_\ell\big(\textstyle\bigotimes u_w\big)\Big]
    For a general input the ancillas are not exactly ∣0⟩\lvert0\rangle. Discarding them is a partial trace, so each reversed layer is a channel from mm to m/2m/2 qubits: a convolution followed by pooling. QCNN pooling is more general than plain discarding, because the conditioned rotation lets the discarded qubit correct its neighbour, the error-correction step of Cong et al.
  4. Step 4:
    ρℓ=Φℓ(ρℓ−1),f=Tr[ZρL]=Tr[(Φ1∗∘⋯∘ΦL∗)(Z) ρ0]\rho_\ell=\Phi_\ell(\rho_{\ell-1}),\qquad f=\mathrm{Tr}\big[Z\rho_L\big]=\mathrm{Tr}\big[(\Phi_1^*\circ\cdots\circ\Phi_L^*)(Z)\,\rho_0\big]
    Coarse-grained states on n,n/2,…,1n,n/2,\dots,1 qubits; in the Heisenberg picture the readout ZZ is pulled back through the dual maps to an nn-qubit observable measured on the input.
  5. Step 5:
    Φℓ=Φ  ∀ℓ:ρℓ=Φℓ(ρ0),ρ⋆=Φ(ρ⋆)\Phi_\ell=\Phi\ \ \forall\ell:\qquad\rho_\ell=\Phi^{\ell}(\rho_0),\qquad\rho^\star=\Phi(\rho^\star)
    If, in addition, the same weights are used at every level, the network iterates one coarse-graining map: a discrete renormalisation-group (RG) flow. States in the same phase flow to the same fixed point, so a readout that distinguishes fixed points classifies phases. The lab's model uses different weights at its two levels, so it is a general multiscale network rather than a scale-invariant one.

Trainability: no barren plateaus#

Deep random circuits have exponentially vanishing gradients, Var[∂C]∼2−n\mathrm{Var}[\partial C]\sim2^{-n} (barren-plateau lesson). A QCNN has a local cost (one measured qubit) and logarithmic depth, and Pesah et al. (2021) proved that this suffices.

Theorem (Pesah, Cerezo, Wang, Volkoff, Sornborger and Coles, 2021). Consider a QCNN on nn qubits whose convolution and pooling blocks are drawn independently from distributions that form local unitary 22-designs, and a cost C=∑ici Tr[O σout(ρi)]C=\sum_ic_i\,\mathrm{Tr}\big[O\,\sigma_{\mathrm{out}}(\rho_i)\big] that is linear in the output states σout(ρi)\sigma_{\mathrm{out}}(\rho_i), with OO a Hermitian operator on the output qubit. Then for every trainable parameter θμ\theta_\mu, E[∂μC]=0\mathbb E[\partial_\mu C]=0 and Var[∂μC] ≥ F(n),F(n)∈Ω(1/poly(n)).\mathrm{Var}\big[\partial_\mu C\big]\ \ge\ F(n),\qquad F(n)\in\Omega\big(1/\mathrm{poly}(n)\big).

Their proof, a graph-based recursion over the random blocks, is not reproduced here. We prove the geometric fact behind it: the influence of any gate reaches the readout through a narrow cone only O(log⁡n)O(\log n) levels long.

Lemma

Light cones in a QCNN

Let n=2Ln=2^L and let gg be any block of the QCNN of the definition. Define its forward light cone as the smallest set of qubits that contains the qubits of gg and also contains all qubits of every later block that touches the set. Then (a) at the start of every later level, the cone contains at most 55 active qubits, which form a contiguous arc of the ring; (b) the cone contains at most 1212 blocks of each level, hence at most 12log⁡2n12\log_2n blocks in total; (c) gg is separated from the readout by at most L=log⁡2nL=\log_2n levels, i.e. by circuit depth at most 1+12log⁡2n1+12\log_2n.

Proof (6 steps)
  1. Step 1:
    S={s,s+1,…,s+w−1}⊂{0,…,m−1} (mod m)S=\{s,s+1,\dots,s+w-1\}\subset\{0,\dots,m-1\}\ (\mathrm{mod}\ m)
    Track the cone at the start of a level as an arc SS of ww consecutive positions in the list of active qubits; the cone of a single block starts as an arc of length 22.
  2. Step 2:
    even sublayer: w↦≤w+2,odd sublayer: w↦≤w+4\text{even sublayer: }w\mapsto\le w+2,\qquad\text{odd sublayer: }w\mapsto\le w+4
    The pairs of one sublayer are disjoint pairs of adjacent positions, so the pairs that touch an arc extend it by at most one position at each end. Two sublayers extend it by at most two at each end.
  3. Step 3:
    pooling: w′≤⌈(w+4)+12⌉=⌈w+52⌉\text{pooling: }w'\le\Big\lceil\frac{(w+4)+1}{2}\Big\rceil=\Big\lceil\frac{w+5}{2}\Big\rceil
    A pooling pair (2k,2k+1)(2k,2k+1) that touches the arc adds at most one position at each end. A position added on the left is even and is discarded, so only the right end can gain a survivor, and the survivors lie in an arc of length ≤w+5\le w+5. Only odd positions survive, an arc of length λ\lambda contains at most ⌈λ/2⌉\lceil\lambda/2\rceil of them, and they are consecutive in the next level's list.
  4. Step 4:
    w≤5 ⇒ w′≤⌈102⌉=5;wfirst≤⌈2+2+12⌉=3w\le5\ \Rightarrow\ w'\le\Big\lceil\frac{10}2\Big\rceil=5;\qquad w_{\text{first}}\le\Big\lceil\frac{2+2+1}{2}\Big\rceil=3
    Induction over levels. The level that contains gg itself leaves at most 33 survivors, since at most one further sublayer follows gg. Every later level maps w≤5w\le5 to w′≤5w'\le5. This proves (a).
  5. Step 5:
    #{pairs meeting an arc of length λ}≤⌊λ2⌋+1:3+4+5=12\#\{\text{pairs meeting an arc of length }\lambda\}\le\Big\lfloor\frac\lambda2\Big\rfloor+1:\qquad3+4+5=12
    Disjoint adjacent pairs meeting an arc of length λ\lambda number at most ⌊λ/2⌋+1\lfloor\lambda/2\rfloor+1. The arc has length ≤5\le5, ≤7\le7 and ≤9\le9 when the even sublayer, the odd sublayer and the pooling layer act, giving at most 33, 44 and 55 blocks per level. This proves (b).
  6. Step 6:
    depth≤1+∑ℓ=1L12=1+12log⁡2n=O(log⁡n)\text{depth}\le1+\sum_{\ell=1}^{L}12=1+12\log_2n=O(\log n)
    Every level has depth at most 1212 (the bound of the parameter-count proposition), and the readout follows level LL. This proves (c).

∎

Derivation

Why logarithmic depth gives polynomial variance

  1. Step 1:
    Var[∂μC] ≳ Var0⋅κ dμ,0<κ<1\mathrm{Var}[\partial_\mu C]\ \gtrsim\ \mathrm{Var}_0\cdot\kappa^{\,d_\mu},\qquad0<\kappa<1
    Assumption (intuition, not a proof): for a local cost, each of the dμd_\mu layers of 22-design blocks between θμ\theta_\mu and the readout reduces the variance by at most a constant factor κ\kappa; Cerezo et al. (2021) prove bounds of this type for local costs in layered circuits.
  2. Step 2:
    dμ≤1+12log⁡2nd_\mu\le1+12\log_2n
    Part (c) of the light-cone lemma. In a QCNN every parameter is close to the output, because pooling halves the register at every level.
  3. Step 3:
    κ1+12log⁡2n=κ⋅(2log⁡2κ)12log⁡2n=κ n−12log⁡2(1/κ)\kappa^{1+12\log_2n}=\kappa\cdot\big(2^{\log_2\kappa}\big)^{12\log_2n}=\kappa\,n^{-12\log_2(1/\kappa)}
    Exponential decay in a depth that is logarithmic in nn is polynomial decay in nn; this is the identity alog⁡2n=nlog⁡2aa^{\log_2n}=n^{\log_2a}.
  4. Step 4:
    Var[∂μC] ≳ Var0 κ n−12log⁡2(1/κ)∈Ω(1/poly(n))\mathrm{Var}[\partial_\mu C]\ \gtrsim\ \mathrm{Var}_0\,\kappa\,n^{-12\log_2(1/\kappa)}\in\Omega\big(1/\mathrm{poly}(n)\big)
    The heuristic reproduces the scaling of the theorem. A deep hardware-efficient ansatz with depth d∝nd\propto n would instead give κcn\kappa^{cn}, an exponential plateau.
  5. Step 5:
    global cost: O=Z⊗n ⇒ Var∼2−n even at depth O(1)\text{global cost: }O=Z^{\otimes n}\ \Rightarrow\ \mathrm{Var}\sim2^{-n}\ \text{even at depth }O(1)
    Locality matters too: a global observable has a plateau at any depth, while the QCNN measures one qubit through a narrow light cone (part (a)).

Quick check

Which pair of properties does the light-cone argument for QCNN trainability rely on?

Select one answer

The lab model, gate by gate#

Derivation

The 4-qubit QCNN of lab-qcnn-bars

  1. Step 1:
    E(x)=⨂q=03RY(πxq),RY(πx)∣0⟩=cos⁡πx2∣0⟩+sin⁡πx2∣1⟩,⟨Zq⟩=cos⁡πxqE(x)=\bigotimes_{q=0}^{3}R_Y(\pi x_q),\qquad R_Y(\pi x)\lvert0\rangle=\cos\tfrac{\pi x}2\lvert0\rangle+\sin\tfrac{\pi x}2\lvert1\rangle,\quad\langle Z_q\rangle=\cos\pi x_q
    Angle encoding of the four pixels xq∈[0,1]x_q\in[0,1] (data parameters x0 to x3). An off pixel (x≈0x\approx0) gives ⟨Z⟩≈1\langle Z\rangle\approx1 and an on pixel (x≈1x\approx1) gives ⟨Z⟩≈−1\langle Z\rangle\approx-1.
  2. Step 2:
    Cij(a)=CNOT(j,i) (RY(i)(a2)⊗RY(j)(a3)) CNOT(i,j) (RY(i)(a0)⊗RY(j)(a1))C_{ij}(a)=\mathrm{CNOT}(j,i)\,\big(R_Y^{(i)}(a_2)\otimes R_Y^{(j)}(a_3)\big)\,\mathrm{CNOT}(i,j)\,\big(R_Y^{(i)}(a_0)\otimes R_Y^{(j)}(a_1)\big)
    The convolution block as a matrix product. In time order it is RY(i,a0)R_Y(i,a_0), RY(j,a1)R_Y(j,a_1), CNOT(i,j)\mathrm{CNOT}(i,j), RY(i,a2)R_Y(i,a_2), RY(j,a3)R_Y(j,a_3), CNOT(j,i)\mathrm{CNOT}(j,i): six gates with four weights.
  3. Step 3:
    L1=C30(p0..3) C12(p0..3) C23(p0..3) C01(p0..3)\mathcal L_1=C_{30}(p_{0..3})\,C_{12}(p_{0..3})\,C_{23}(p_{0..3})\,C_{01}(p_{0..3})
    Layer 1 on the ring pairs in the time order (0,1),(2,3),(1,2),(3,0)(0,1),(2,3),(1,2),(3,0), all with the shared weights p0,…,p3p_0,\dots,p_3: the even sublayer, then the odd one.
  4. Step 4:
    Q1=P2→3(p4,p5) P0→1(p4,p5),Pc→t(b0,b1)=∣0⟩⟨0∣c⊗RX(t)(b1)+∣1⟩⟨1∣c⊗RZ(t)(b0)\mathcal Q_1=P_{2\to3}(p_4,p_5)\,P_{0\to1}(p_4,p_5),\qquad P_{c\to t}(b_0,b_1)=\lvert0\rangle\langle0\rvert_c\otimes R_X^{(t)}(b_1)+\lvert1\rangle\langle1\rvert_c\otimes R_Z^{(t)}(b_0)
    Pooling layer 1 with the shared weights p4,p5p_4,p_5, each block made of the four gates CRZCR_Z, XX, CRXCR_X, XX. Qubits 00 and 22 are not used again, so by the deferred-measurement theorem they are measured and discarded.
  5. Step 5:
    L2=C13(p6..9),Q2=P1→3(p10,p11)\mathcal L_2=C_{13}(p_{6..9}),\qquad\mathcal Q_2=P_{1\to3}(p_{10},p_{11})
    Level 2 on the active qubits (1,3)(1,3). The single convolution acts on all remaining qubits, which makes it the fully connected layer.
  6. Step 6:
    fp(x)=⟨0000∣E†L1†Q1†L2†Q2† Z3 Q2L2Q1L1E∣0000⟩,y^=sign fp(x)f_p(x)=\langle0000\rvert E^\dagger\mathcal L_1^\dagger\mathcal Q_1^\dagger\mathcal L_2^\dagger\mathcal Q_2^\dagger\,Z_3\,\mathcal Q_2\mathcal L_2\mathcal Q_1\mathcal L_1E\lvert0000\rangle,\qquad\hat y=\mathrm{sign}\,f_p(x)
    The output ⟨Z3⟩\langle Z_3\rangle (Pauli word IIIZ), exactly what the lab's grader evaluates.
  7. Step 7:
    4+4⋅6+2⋅4+6+4=46 gates;p0..p3: 4×,p4,p5: 2×,p6..p11: 1×4+4\cdot6+2\cdot4+6+4=46\ \text{gates};\qquad p_0..p_3:\ 4\times,\quad p_4,p_5:\ 2\times,\quad p_6..p_{11}:\ 1\times
    Gate count and the number of gates in which each weight occurs; these numbers determine the cost of the gradient below.

Circuit · 4 qubits

Quantum circuit on 4 qubitsRY(2.83) on q0; RY(2.98) on q1; RY(0.31) on q2; RY(0.16) on q3; RY(0.08) on q0; RY(6.16) on q1; X on q1 controlled by q0; RY(1.80) on q0; RY(4.72) on q1; X on q0 controlled by q1; RY(0.08) on q2; RY(6.16) on q3; X on q3 controlled by q2; RY(1.80) on q2; RY(4.72) on q3; X on q2 controlled by q3; RY(0.08) on q1; RY(6.16) on q2; X on q2 controlled by q1; RY(1.80) on q1; RY(4.72) on q2; X on q1 controlled by q2; RY(0.08) on q3; RY(6.16) on q0; X on q0 controlled by q3; RY(1.80) on q3; RY(4.72) on q0; X on q3 controlled by q0; RZ(3.78) on q1 controlled by q0; X on q0; RX(3.14) on q1 controlled by q0; X on q0; RZ(3.78) on q3 controlled by q2; X on q2; RX(3.14) on q3 controlled by q2; X on q2; RY(-0.12) on q1; RY(3.97) on q3; X on q3 controlled by q1; RY(0.05) on q1; RY(3.55) on q3; X on q1 controlled by q3; RZ(4.39) on q3 controlled by q1; X on q1; RX(3.46) on q3 controlled by q1; X on q1q0q1q2q3RY(2.83)RY(2.98)RY(0.31)RY(0.16)RY(0.08)RY(6.16)RY(1.80)RY(4.72)RY(0.08)RY(6.16)RY(1.80)RY(4.72)RY(0.08)RY(6.16)RY(1.80)RY(4.72)RY(0.08)RY(6.16)RY(1.80)RY(4.72)RZ(3.78)XRX(3.14)XRZ(3.78)XRX(3.14)XRY(-0.12)RY(3.97)RY(0.05)RY(3.55)RZ(4.39)XRX(3.46)X

The lab QCNN with the horizontal-bar image x=(0.9,0.95,0.1,0.05)x=(0.9,0.95,0.1,0.05) encoded and the trained weights (rounded to four decimals) bound to numbers. The probability of measuring qubit 33 in ∣0⟩\lvert0\rangle is 12(1+⟨Z3⟩)≈0.974\tfrac12(1+\langle Z_3\rangle)\approx0.974, so the image is classified as horizontal (y^=+1\hat y=+1).

  • |0000⟩0.0001
  • |0001⟩0.0045
  • |0010⟩0.0001
  • |0011⟩0.0006
  • |0100⟩0.013
  • |0101⟩0.014
  • |0110⟩0.0001
  • |0111⟩0.0001
  • |1000⟩0.0677
  • |1001⟩0.0023
  • |1010⟩0.022
  • |1011⟩0.003
  • |1100⟩0.8657
  • |1101⟩0.0009
  • |1110⟩0.0057
  • |1111⟩0.0002
Derivation

With all weights zero the network computes cos(pi x1) cos(pi x3)

  1. Step 1:
    p=0:RY(0)=CRZ(0)=CRX(0)=I ⇒ Pc→t=XcXc=I,Cij=CNOT(j,i) CNOT(i,j)p=0:\quad R_Y(0)=CR_Z(0)=CR_X(0)=I\ \Rightarrow\ P_{c\to t}=X_cX_c=I,\qquad C_{ij}=\mathrm{CNOT}(j,i)\,\mathrm{CNOT}(i,j)
    All rotations become identities; only the CNOT pairs of the convolution blocks remain.
  2. Step 2:
    CNOT(c,t) Zc CNOT(c,t)=Zc,CNOT(c,t) Zt CNOT(c,t)=ZcZt\mathrm{CNOT}(c,t)\,Z_c\,\mathrm{CNOT}(c,t)=Z_c,\qquad\mathrm{CNOT}(c,t)\,Z_t\,\mathrm{CNOT}(c,t)=Z_cZ_t
    Heisenberg rule for a CNOT, which is its own inverse: on ∣a,b⟩\lvert a,b\rangle the gate maps the target to b⊕ab\oplus a, so ZtZ_t picks up the sign (−1)a(-1)^a of the control.
  3. Step 3:
    Z3 →CNOT(3,1) Z3 →CNOT(1,3) Z1Z3Z_3\ \xrightarrow{\mathrm{CNOT}(3,1)}\ Z_3\ \xrightarrow{\mathrm{CNOT}(1,3)}\ Z_1Z_3
    Pull Z3Z_3 back through C13C_{13}, last gate first.
  4. Step 4:
    Z1Z3 →CNOT(0,3) Z0Z1Z3 →CNOT(3,0) Z0Z1Z_1Z_3\ \xrightarrow{\mathrm{CNOT}(0,3)}\ Z_0Z_1Z_3\ \xrightarrow{\mathrm{CNOT}(3,0)}\ Z_0Z_1
    Through C30C_{30}: CNOT(0,3)\mathrm{CNOT}(0,3) maps Z3↦Z0Z3Z_3\mapsto Z_0Z_3; then CNOT(3,0)\mathrm{CNOT}(3,0) maps Z0↦Z3Z0Z_0\mapsto Z_3Z_0 and fixes Z3Z_3, and Z32=IZ_3^2=I.
  5. Step 5:
    Z0Z1 →CNOT(2,1) Z0Z1Z2 →CNOT(1,2) Z0Z2Z_0Z_1\ \xrightarrow{\mathrm{CNOT}(2,1)}\ Z_0Z_1Z_2\ \xrightarrow{\mathrm{CNOT}(1,2)}\ Z_0Z_2
    Through C12C_{12}: Z1↦Z2Z1Z_1\mapsto Z_2Z_1, then Z2↦Z1Z2Z_2\mapsto Z_1Z_2 and Z12=IZ_1^2=I.
  6. Step 6:
    Z0Z2 →CNOT(3,2) Z0Z2Z3 →CNOT(2,3) Z0Z3Z_0Z_2\ \xrightarrow{\mathrm{CNOT}(3,2)}\ Z_0Z_2Z_3\ \xrightarrow{\mathrm{CNOT}(2,3)}\ Z_0Z_3
    Through C23C_{23}: Z2↦Z3Z2Z_2\mapsto Z_3Z_2, then Z3↦Z2Z3Z_3\mapsto Z_2Z_3 and Z22=IZ_2^2=I.
  7. Step 7:
    Z0Z3 →CNOT(1,0) Z0Z1Z3 →CNOT(0,1) Z1Z3Z_0Z_3\ \xrightarrow{\mathrm{CNOT}(1,0)}\ Z_0Z_1Z_3\ \xrightarrow{\mathrm{CNOT}(0,1)}\ Z_1Z_3
    Through C01C_{01}, the first block in time: Z0↦Z1Z0Z_0\mapsto Z_1Z_0, then Z1↦Z0Z1Z_1\mapsto Z_0Z_1 and Z02=IZ_0^2=I.
  8. Step 8:
    f0(x)=⟨Z1Z3⟩E(x)∣0000⟩=cos⁡(πx1)cos⁡(πx3)f_0(x)=\langle Z_1Z_3\rangle_{E(x)\lvert0000\rangle}=\cos(\pi x_1)\cos(\pi x_3)
    The encoded state is a product state, so the expectation value factorises into ⟨Z1⟩⟨Z3⟩\langle Z_1\rangle\langle Z_3\rangle.
  9. Step 9:
    xon∈[0.75,1)⇒cos⁡πx∈(−1,−22],xoff∈[0,0.25)⇒cos⁡πx∈(22,1]x_{\text{on}}\in[0.75,1)\Rightarrow\cos\pi x\in(-1,-\tfrac{\sqrt2}2],\qquad x_{\text{off}}\in[0,0.25)\Rightarrow\cos\pi x\in(\tfrac{\sqrt2}2,1]
    The pixel ranges of the bars dataset.
  10. Step 10:
    y=+1 (1100,0011): f0≤−12;y=−1 (1010,0101): f0≥12y=+1\ (\texttt{1100},\texttt{0011}):\ f_0\le-\tfrac12;\qquad y=-1\ (\texttt{1010},\texttt{0101}):\ f_0\ge\tfrac12
    In a horizontal bar exactly one of the pixels q1,q3q_1,q_3 is on, so the product is negative. In a vertical bar both or neither are on, so it is positive. Its magnitude is at least 22⋅22=12\frac{\sqrt2}2\cdot\frac{\sqrt2}2=\frac12. Zero weights therefore classify every image with the wrong sign (accuracy 00), and training must essentially flip this sign.
Proposition

Shift rules for the pooling weights

Let θ\theta be the angle of one pooling gate CRP(c,t,θ)CR_P(c,t,\theta), P∈{Z,X}P\in\{Z,X\}, of the lab QCNN. (a) Its generator G=∣1⟩⟨1∣c⊗12PG=\lvert1\rangle\langle1\rvert_c\otimes\tfrac12P has the spectrum {0,0,12,−12}\{0,0,\tfrac12,-\tfrac12\}, so for a general circuit f(θ)f(\theta) contains the frequencies 12\tfrac12 and 11, and the four-term rule f′(θ)=c+[f(θ+π2)−f(θ−π2)]−c−[f(θ+3π2)−f(θ−3π2)]f'(\theta)=c_+\big[f(\theta+\tfrac\pi2)-f(\theta-\tfrac\pi2)\big]-c_-\big[f(\theta+\tfrac{3\pi}2)-f(\theta-\tfrac{3\pi}2)\big], c±=2±142c_\pm=\frac{\sqrt2\pm1}{4\sqrt2}, is exact. The engine applies this rule to every controlled rotation. (b) In the QCNN the gate-isolated observable BB commutes with ZcZ_c, since cc is afterwards used only as a control; the frequency-12\tfrac12 part vanishes and the two-term rule 12[f(θ+π2)−f(θ−π2)]\tfrac12\big[f(\theta+\tfrac\pi2)-f(\theta-\tfrac\pi2)\big] is exact as well. (c) Summing over the occurrences of each shared weight, one full gradient costs 6464 shifted evaluations with the four-term rule for the pooling gates and 5252 with the two-term rule.

Proof (7 steps)
  1. Step 1:
    CRP(θ)=∣0⟩⟨0∣⊗I+∣1⟩⟨1∣⊗e−iθP/2=e−iθG,G=(00012P)CR_P(\theta)=\lvert0\rangle\langle0\rvert\otimes I+\lvert1\rangle\langle1\rvert\otimes e^{-i\theta P/2}=e^{-i\theta G},\qquad G=\begin{pmatrix}0&0\\0&\tfrac12P\end{pmatrix}
    The generator is block diagonal. The control-00 block contributes the eigenvalue 00 twice, and the control-11 block contributes the eigenvalues ±12\pm\tfrac12 of 12P\tfrac12P.
  2. Step 2:
    f(θ)=a0+a1cos⁡θ2+b1sin⁡θ2+a2cos⁡θ+b2sin⁡θ,a1−ib1=2(z+0+z0−),zjk=⟨ψ∣ΠjBΠk∣ψ⟩f(\theta)=a_0+a_1\cos\tfrac\theta2+b_1\sin\tfrac\theta2+a_2\cos\theta+b_2\sin\theta,\qquad a_1-ib_1=2\big(z_{+0}+z_{0-}\big),\quad z_{jk}=\langle\psi\vert\Pi_jB\Pi_k\vert\psi\rangle
    The spectrum theorem for controlled rotations from the parameter-shift lesson: the frequencies are the eigenvalue differences {0,±12,±1}\{0,\pm\tfrac12,\pm1\}, with Π0=∣0⟩⟨0∣⊗I\Pi_0=\lvert0\rangle\langle0\rvert\otimes I and Π±=∣1⟩⟨1∣⊗12(I±P)\Pi_\pm=\lvert1\rangle\langle1\rvert\otimes\tfrac12(I\pm P).
  3. Step 3:
    (111−1)(c+c−)=(12122) ⇒ c±=2±142=0.4267766953, 0.0732233047\begin{pmatrix}1&1\\1&-1\end{pmatrix}\begin{pmatrix}c_+\\c_-\end{pmatrix}=\begin{pmatrix}\tfrac12\\\tfrac1{2\sqrt2}\end{pmatrix}\ \Rightarrow\ c_\pm=\frac{\sqrt2\pm1}{4\sqrt2}=0.4267766953,\ 0.0732233047
    Exactness on both frequencies, 2ω[c+sin⁡ωπ2−c−sin⁡3ωπ2]=1\frac2\omega\big[c_+\sin\frac{\omega\pi}2-c_-\sin\frac{3\omega\pi}2\big]=1 for ω=1\omega=1 and ω=12\omega=\tfrac12, gives this 2×22\times2 system (derived in the parameter-shift lesson). This proves (a).
  4. Step 4:
    CRZ(c,t,b0): B=∑m∣m⟩⟨m∣c⊗Wm†KWm;CRX(c,t,b1): B=Xc (Ic⊗K) Xc=Ic⊗KCR_Z(c,t,b_0):\ B=\sum_m\lvert m\rangle\langle m\rvert_c\otimes W_m^\dagger KW_m;\qquad CR_X(c,t,b_1):\ B=X_c\,(I_c\otimes K)\,X_c=I_c\otimes K
    After CRZCR_Z, the only later gates on cc are X(c) CRX X(c)=∑m∣m⟩⟨m∣⊗WmX(c)\,CR_X\,X(c)=\sum_m\lvert m\rangle\langle m\rvert\otimes W_m, and the remaining gates and Z3Z_3 form an observable KK that does not act on cc. After CRXCR_X only X(c)X(c) touches cc. In both cases BB commutes with ∣m⟩⟨m∣c⊗I\lvert m\rangle\langle m\rvert_c\otimes I.
  5. Step 5:
    Π±BΠ0=Π±(∣1⟩⟨1∣c⊗I)B(∣0⟩⟨0∣c⊗I)Π0=Π±B(∣1⟩⟨1∣0⟩⟨0∣c⊗I)Π0=0\Pi_\pm B\Pi_0=\Pi_\pm\big(\lvert1\rangle\langle1\rvert_c\otimes I\big)B\big(\lvert0\rangle\langle0\rvert_c\otimes I\big)\Pi_0=\Pi_\pm B\big(\lvert1\rangle\langle1\vert0\rangle\langle0\rvert_c\otimes I\big)\Pi_0=0
    Π±\Pi_\pm lies in the control-11 block and Π0\Pi_0 in the control-00 block. Moving the projector through BB produces the product of orthogonal projectors. In the same way Π0BΠ−=0\Pi_0B\Pi_-=0.
  6. Step 6:
    z+0=z0−=0 ⇒ a1=b1=0,f(θ)=a0+a2cos⁡θ+b2sin⁡θz_{+0}=z_{0-}=0\ \Rightarrow\ a_1=b_1=0,\qquad f(\theta)=a_0+a_2\cos\theta+b_2\sin\theta
    Only the frequency 1=2r1=2r with r=12r=\tfrac12 survives. The general shift rule with s=π2s=\tfrac\pi2 then gives the two-term rule exactly, which proves (b). This is the gradient counterpart of the deferred-measurement theorem: coherences between the two control values never reach the output. The rule fails as soon as cc is used again, for example by H(c)H(c) followed by CNOT(c,3)\mathrm{CNOT}(c,3), as the TypeScript cell shows.
  7. Step 7:
    ∂f∂pk=∑g: θg=pk∂f∂θg,4⋅4⋅2+2⋅2⋅4+4⋅2+2⋅4=64,32+2⋅2⋅2+8+2⋅2=52\frac{\partial f}{\partial p_k}=\sum_{g:\,\theta_g=p_k}\frac{\partial f}{\partial\theta_g},\qquad4\cdot4\cdot2+2\cdot2\cdot4+4\cdot2+2\cdot4=64,\qquad32+2\cdot2\cdot2+8+2\cdot2=52
    Chain rule for shared weights. In the first count, the 1616 RYR_Y occurrences of p0,…,p3p_0,\dots,p_3 cost 22 evaluations each; the 44 pooling occurrences of p4,p5p_4,p_5 cost 44 each; p6,…,p9p_6,\dots,p_9 cost 22 each; and p10,p11p_{10},p_{11} cost 44 each. The second count uses 22 evaluations per pooling occurrence. This proves (c).

∎

Quick check

The engine computes ∇pfp(x)\nabla_pf_p(x) of the lab QCNN for one image, using the two-term rule for RYR_Y gates and the four-term rule for controlled rotations, plus one unshifted evaluation for the value fp(x)f_p(x). How many circuit evaluations does one call make in total?

tolerance ±0.5

The TypeScript cell evaluates the trained model, prints the engine gradient (∂f/∂p10=0\partial f/\partial p_{10}=0, as the dual channel predicts) and applies the four-term and two-term rules by hand to the pooling weights. They agree, as part (b) predicts, until the pooled qubit 00 is used again.

TypeScriptrunnable
import { FOUR_TERM_C_MINUS, FOUR_TERM_C_PLUS, expectationValue, parameterShiftGradient } from '@/lib/quantum-simulator';
import { barsDataset, qcnnParameterCount, qcnnPredict, qcnnTemplate } from '@/lib/qml';

// Trained weights of the lab's reference solution, rounded to 4 decimals.
const p: Record<string, number> = {
  p0: 0.0778, p1: 6.1613, p2: 1.7979, p3: 4.7243, p4: 3.7777, p5: 3.14,
  p6: -0.1153, p7: 3.9739, p8: 0.0467, p9: 3.5536, p10: 4.3858, p11: 3.4631,
};
const names = Object.keys(p);
const template = qcnnTemplate();
const Z3 = [{ coeff: 1, ops: 'IIIZ' }];

const horizontal = [0.9, 0.95, 0.1, 0.05];
const vertical = [0.9, 0.1, 0.95, 0.05];
console.log('<Z3> horizontal ' + qcnnPredict(p, horizontal).toFixed(10) + ', vertical ' + qcnnPredict(p, vertical).toFixed(10));
console.log('gates ' + template.ops.length + ', shared weights P(4) = ' + qcnnParameterCount(4) + ', P(8) = ' + qcnnParameterCount(8) + ', P(16) = ' + qcnnParameterCount(16));

// Exact gradient from the engine: two-term rule for the RY weights, four-term rule for the CRZ/CRX weights.
const bindings: Record<string, number> = { x0: 0.9, x1: 0.95, x2: 0.1, x3: 0.05, ...p };
const g = parameterShiftGradient(template, Z3, { bindings, params: names });
console.log('evaluations ' + g.evaluations + ' (1 unshifted + 64 shifted)');
console.log('gradient ' + names.map((n) => n + ' ' + g.gradient[n].toFixed(6)).join(', '));

// By hand: shift one gate occurrence of weight w at a time and sum over the occurrences (chain rule).
function rules(circuit: any, w: string): string {
  const value = (gate: number, s: number) => {
    const c = { ...circuit, ops: circuit.ops.map((op: any, k: number) => (k === gate ? { ...op, params: [{ ...op.params[0], offset: s }] } : op)) };
    return expectationValue(c, Z3, bindings);
  };
  const diff = (gate: number, s: number) => value(gate, s) - value(gate, -s);
  const gates: number[] = circuit.ops.flatMap((op: any, k: number) => (op.params?.[0]?.param === w ? [k] : []));
  const four = gates.reduce((sum, k) => sum + FOUR_TERM_C_PLUS * diff(k, Math.PI / 2) - FOUR_TERM_C_MINUS * diff(k, 1.5 * Math.PI), 0);
  const two = gates.reduce((sum, k) => sum + 0.5 * diff(k, Math.PI / 2), 0);
  return w + ' (gates ' + gates.join(', ') + '): four-term ' + four.toFixed(6) + ', two-term ' + two.toFixed(6);
}
for (const w of ['p4', 'p5', 'p11']) console.log('QCNN        ' + rules(template, w));
// The same weight when the pooled qubit 0 is used again afterwards: H(0), CNOT(0, 3) appended.
const reused = { ...template, ops: [...template.ops, { kind: 'gate', gate: 'H', targets: [0] }, { kind: 'gate', gate: 'CNOT', targets: [0, 3] }] };
console.log('reused ctrl ' + rules(reused, 'p4'));

const test = barsDataset(12, 100);
const correct = test.X.filter((x, m) => Math.sign(qcnnPredict(p, x)) === test.y[m]).length;
console.log('held-out accuracy ' + (correct / test.X.length).toFixed(2));

Expected output

<Z3> horizontal 0.9487576298, vertical -0.9026268265
gates 46, shared weights P(4) = 12, P(8) = 18, P(16) = 24
evaluations 65 (1 unshifted + 64 shifted)
gradient p0 0.298714, p1 0.234418, p2 0.071498, p3 -0.034939, p4 -0.005194, p5 -0.004013, p6 0.014123, p7 -0.013223, p8 0.012624, p9 0.015969, p10 0.000000, p11 -0.036193
QCNN        p4 (gates 28, 32): four-term -0.005194, two-term -0.005194
QCNN        p5 (gates 30, 34): four-term -0.004013, two-term -0.004013
QCNN        p11 (gates 44): four-term -0.036193, two-term -0.036193
reused ctrl p4 (gates 28, 32): four-term -0.040768, two-term -0.058111
held-out accuracy 1.00

The NumPy cell rebuilds the network from explicit 16×1616\times16 matrices, reproduces ⟨Z3⟩\langle Z_3\rangle to ten digits, confirms f0=cos⁡πx1cos⁡πx3f_0=\cos\pi x_1\cos\pi x_3, checks the pooling theorem on a random mixed state and regenerates the held-out images with a port of mulberry32.

Pythonrunnable
import numpy as np

# The lab's 4-qubit QCNN with dense 16 x 16 matrices (qubit 0 = most significant bit).
I2 = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
Z = np.diag([1.0 + 0j, -1.0])
P0, P1 = np.diag([1.0 + 0j, 0.0]), np.diag([0.0 + 0j, 1.0])


def ry(t):
    return np.array([[np.cos(t / 2), -np.sin(t / 2)], [np.sin(t / 2), np.cos(t / 2)]], dtype=complex)


def rx(t):
    return np.array([[np.cos(t / 2), -1j * np.sin(t / 2)], [-1j * np.sin(t / 2), np.cos(t / 2)]])


def rz(t):
    return np.diag([np.exp(-0.5j * t), np.exp(0.5j * t)])


def on(U, q, n=4):  # U on qubit q, identity on the others
    out = np.eye(1, dtype=complex)
    for k in range(n):
        out = np.kron(out, U if k == q else I2)
    return out


def ctrl(c, t, U, n=4):  # |0><0|_c (x) I + |1><1|_c (x) U_t
    return on(P0, c, n) + on(P1, c, n) @ on(U, t, n)


def conv(i, j, a):  # C_ij(a0, a1, a2, a3), gates in time order
    return [on(ry(a[0]), i), on(ry(a[1]), j), ctrl(i, j, X), on(ry(a[2]), i), on(ry(a[3]), j), ctrl(j, i, X)]


def pool(c, t, b):  # P_{c->t}(b0, b1) = CRZ(c,t,b0) X(c) CRX(c,t,b1) X(c)
    return [ctrl(c, t, rz(b[0])), on(X, c), ctrl(c, t, rx(b[1])), on(X, c)]


def qcnn(x, p):
    gates = [on(ry(np.pi * x[q]), q) for q in range(4)]
    for i, j in [(0, 1), (2, 3), (1, 2), (3, 0)]:
        gates += conv(i, j, p[0:4])
    gates += pool(0, 1, p[4:6]) + pool(2, 3, p[4:6]) + conv(1, 3, p[6:10]) + pool(1, 3, p[10:12])
    psi = np.zeros(16, dtype=complex)
    psi[0] = 1
    for G in gates:
        psi = G @ psi
    return np.real(np.vdot(psi, on(Z, 3) @ psi))


p = np.array([0.0778, 6.1613, 1.7979, 4.7243, 3.7777, 3.14, -0.1153, 3.9739, 0.0467, 3.5536, 4.3858, 3.4631])
for name, x in (("horizontal [0.9, 0.95, 0.1, 0.05]", [0.9, 0.95, 0.1, 0.05]), ("vertical   [0.9, 0.1, 0.95, 0.05]", [0.9, 0.1, 0.95, 0.05])):
    f = qcnn(x, p)
    print(f"{name}: <Z3> = {f:+.10f}, prediction {int(np.sign(f)):+d}")

# All weights zero: <Z3> = cos(pi x1) cos(pi x3).
x = [0.9, 0.95, 0.1, 0.05]
print(f"zero weights: <Z3> = {qcnn(x, np.zeros(12)):+.10f}, cos(pi x1) cos(pi x3) = {np.cos(np.pi * x[1]) * np.cos(np.pi * x[3]):+.10f}")

# Pooling = measure c, rotate t by V_m, discard c (deferred measurement), on a random two-qubit density matrix.
rng = np.random.default_rng(53)
A = rng.normal(size=(4, 4)) + 1j * rng.normal(size=(4, 4))
rho = A @ A.conj().T
rho /= np.trace(rho)
b0, b1 = 0.7, -1.3
U = on(X, 0, 2) @ ctrl(0, 1, rx(b1), 2) @ on(X, 0, 2) @ ctrl(0, 1, rz(b0), 2)
sigma = U @ rho @ U.conj().T
deferred = sigma[:2, :2] + sigma[2:, 2:]  # Tr_c: sum of the diagonal 2 x 2 blocks
measured = rx(b1) @ rho[:2, :2] @ rx(b1).conj().T + rz(b0) @ rho[2:, 2:] @ rz(b0).conj().T
print("pooling: Tr_c(U rho U^dag) equals the measured-and-rotated state:", bool(np.max(np.abs(deferred - measured)) < 1e-12))


# The 100 held-out images of the lab: port of mulberry32 and barsDataset(12, 100).
def mulberry32(seed):
    a = seed & 0xFFFFFFFF

    def imul(u, v):
        return (u * v) & 0xFFFFFFFF

    def r():
        nonlocal a
        a = (a + 0x6D2B79F5) & 0xFFFFFFFF
        t = imul(a ^ (a >> 15), 1 | a)
        t = ((t + imul(t ^ (t >> 7), 61 | t)) & 0xFFFFFFFF) ^ t
        return (t ^ (t >> 14)) / 4294967296

    return r


def bars(seed, count):
    r = mulberry32(seed)
    data = []
    for _ in range(count):
        y = 1 if r() < 0.5 else -1
        k = 0 if r() < 0.5 else 1
        pattern = ("1100", "0011")[k] if y == 1 else ("1010", "0101")[k]
        data.append(([0.75 + 0.25 * r() if c == "1" else 0.25 * r() for c in pattern], y))
    return data


test = bars(12, 100)
correct = sum(int(np.sign(qcnn(x, p)) == y) for x, y in test)
print(f"held-out images: {len(test)}, first {np.round(test[0][0], 4).tolist()} (label {test[0][1]:+d}), accuracy {correct / len(test):.2f}")

Expected output

horizontal [0.9, 0.95, 0.1, 0.05]: <Z3> = +0.9487576298, prediction +1
vertical   [0.9, 0.1, 0.95, 0.05]: <Z3> = -0.9026268265, prediction -1
zero weights: <Z3> = -0.9755282581, cos(pi x1) cos(pi x3) = -0.9755282581
pooling: Tr_c(U rho U^dag) equals the measured-and-rotated state: True
held-out images: 100, first [0.895, 0.9853, 0.0382, 0.0034] (label +1), accuracy 1.00

Training. The lab's reference solution starts from random weights 2πu2\pi u (uu from mulberry32(9); 49%49\% held-out accuracy) and runs 3030 full-batch Adam steps (learning rate 0.10.1) on the mean squared error 140∑m(fp(xm)−ym)2\frac1{40}\sum_m\big(f_p(x_m)-y_m\big)^2. The loss falls from 1.011.01 at the first step to 0.0260.026 at the thirtieth, and all 100100 held-out images are classified correctly; plain gradient descent with learning rate 0.50.5 from the same start reaches a training loss of 0.0390.039 after 2020 steps and 0.0240.024 after 6060. The task is easy because the label is the sign of −⟨Z1Z3⟩-\langle Z_1Z_3\rangle, which the CNOT skeleton already measures. The weight p10p_{10} never changes under gradient descent: its gradient is identically zero.

References

  1. I. Cong, S. Choi and M. D. Lukin, Quantum convolutional neural networks, Nature Physics 15, 1273–1278 (2019).doi:10.1038/s41567-019-0648-8
  2. A. Pesah, M. Cerezo, S. Wang, T. Volkoff, A. T. Sornborger and P. J. Coles, Absence of barren plateaus in quantum convolutional neural networks, Physical Review X 11, 041011 (2021).doi:10.1103/PhysRevX.11.041011
  3. T. Hur, L. Kim and D. K. Park, Quantum convolutional neural network for classical data classification, Quantum Machine Intelligence 4, 3 (2022).doi:10.1007/s42484-021-00061-x
  4. I. MacCormack, C. Delaney, A. Galda, N. Aggarwal and P. Narang, Branching quantum convolutional neural networks, arXiv:2012.14439 (2020).arxiv.org
  5. G. Vidal, Class of quantum many-body states that can be efficiently simulated, Physical Review Letters 101, 110501 (2008).doi:10.1103/PhysRevLett.101.110501
  6. M. Cerezo, A. Sone, T. Volkoff, L. Cincio and P. J. Coles, Cost function dependent barren plateaus in shallow parametrized quantum circuits, Nature Communications 12, 1791 (2021).doi:10.1038/s41467-021-21728-w

Hands-on labs

  • Train a QCNN to tell horizontal from vertical bars

    1 step · auto-graded

    Train the 4-qubit quantum convolutional neural network of the lesson, with 1212 shared weights, on 2×22\times2 images of horizontal and vertical bars. Your TypeScript function receives 4040 training images and returns the weights p0 to p11. You write the loss, the gradient and the optimiser. For the gradient, the engine's parameterShiftGradient applies the two-term rule to the RYR_Y weights and the four-term rule to the CRZCR_Z/CRXCR_X pooling weights. The grader binds your weights into the fixed QCNN circuit and classifies 100100 held-out images by sign⟨Z3⟩\mathrm{sign}\langle Z_3\rangle; at least 90%90\% must be correct.

    Open lab