Variational Classifiers
A variational quantum classifier (VQC) is a parameterized circuit trained to assign labels. It combines the feature map of the kernel lesson with a trainable ansatz, then reads out a prediction from a measured expectation value. Mitarai et al. (2018) and Havlíček et al. (2019) introduced this "quantum circuit learning" template.
Anatomy of the model
The circuit has three stages applied to :
- Encoding — the fixed feature map that loads the data (e.g. angle encoding ).
- Ansatz — trainable rotations (and entangling gates for more than one qubit) whose parameters are learned.
- Readout — measure an observable, typically on one qubit, and map its sign to a class.
The prediction is
and the class is .
A one-qubit example
The smallest non-trivial VQC uses a single qubit. With a scalar feature encoded by and a two-angle trainable block , the prepared state is
Even this tiny model can separate simple 1-D data: training rotates the Bloch vector so that points of one class land in the upper hemisphere () and the other class in the lower hemisphere.
Training the parameters
The classical loop minimizes a loss — for binary labels , a common choice is the squared error averaged over the dataset. Gradients of with respect to each come from the parameter-shift rule (Module 7): for a rotation generated by a Pauli,
These exact analytic gradients feed an ordinary optimizer (gradient descent, Adam) that updates .
Try it
Prepare the state of a one-qubit variational classifier for the input with the trained parameters (an ) and (an ). Apply the gates in the order encoding, then , then — i.e. build
The grader checks the resulting state vector.
Sign in on the full site to ask questions and join the discussion.