Current parameters θ Shift-rule eval points High cost Low cost

Parameter-Shift Rule (2D): Training a Quantum Neural Network

A quantum neural network is a parameterized quantum circuit whose rotation angles play the role of weights, trained by gradient descent just like a classical network — except a quantum computer cannot backpropagate. This 2D simulator renders the cost landscape of a single-qubit QNN, R_z(θ₂)R_y(θ₁)|0⟩ measured in X, as a live heatmap over the two rotation angles, and trains it using the exact parameter-shift rule: at every step the circuit is re-evaluated at each parameter shifted by ±π/2, and the difference of those two runs gives the true gradient. Watch the marker slide downhill toward whatever target expectation value you set, with the four shift-rule evaluation points highlighted at each step, a live loss curve tracking the cost across training iterations, and readouts of the cost, output, both angles and the gradient magnitude.