Home▸Machine Learning & Neural Networks▸Quantum Advanced Quantum Machine Learning Simulation

Quantum Data Re-Uploading Classifier

Train a single-qubit quantum classifier live: watch a Bloch-sphere state get re-encoded and rotated layer by layer, track the decision boundary sharpen on a 2D dataset, and see the exact parameter-shift gradients driving the learning.

Machine Learning & Neural Networks2DModerate60 FPS📱 Mobile-adapted
Quantum Advanced Quantum Machine Learning Simulation ↗ Open standalone

This simulation trains a real single-qubit quantum machine learning model — the "data re-uploading" classifier — on a 2D dataset, live in the browser. A classical feature (x, y) is repeatedly encoded onto a qubit's Bloch sphere and interleaved with trainable rotations across configurable layers; gradient descent uses the exact quantum parameter-shift rule to update those rotation angles every epoch, sharpening the decision boundary shown on the 2D panel while the 3D Bloch sphere animates the exact rotation trajectory a probed point takes through the circuit. Switch between a circular and an XOR-shaped target concept, add re-upload layers to increase the qubit's expressivity, and watch loss and accuracy converge as the single qubit learns to classify data it was never explicitly programmed to separate.

⚙ Under the hood

This simulation explores the complex interplay between quantum mechanics and machine learning algorithms, allowing users to visualize how quantum phenomena can be leveraged for enhanced computational capabilities. By manipulating simulated quantum systems, learners can observe the potential impact on machine learning processes like pattern recognition and data analysis.

Quantum Machine Learning

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

About this simulation

Quantum Data Re-Uploading Classifier: Single-Qubit Machine Learning

Overview

Quantum machine learning does not require thousands of qubits to demonstrate a useful learning principle. In a quantum data re-uploading classifier, an input such as a two-dimensional point is encoded repeatedly into a single qubit, alternating with adjustable quantum rotations. MySimulator’s interactive model shows how these layers create a trainable decision rule. Users can compare circular and XOR-style datasets, watch the classification boundary evolve, inspect a Bloch-sphere representation and follow optimisation using parameter-shift gradients.

How one qubit can express a decision

A pure qubit state can be pictured as a point on the Bloch sphere. Single-qubit rotations change the state, and a measurement converts its final orientation into outcome probabilities. A classifier can map an input vector (x, y) to rotation angles and then measure an expectation value, such as the Z-axis Pauli observable. Thresholding that output produces a class prediction. Although the quantum state occupies a two-dimensional complex vector space, repeated nonlinear dependence on input angles can create interesting decision boundaries in ordinary feature space.

Why features are re-uploaded

A single encoding layer may be too restrictive to separate patterns such as rings or XOR configurations. Data re-uploading applies the same input features across multiple layers, with trainable rotations between encodings. Repeated angular transformations enlarge the variety of functions represented by the circuit. This is a form of model expressivity, not a claim that the qubit stores an unlimited amount of classical information. Adding layers can help fitting a target pattern while also increasing training cost and potentially complicating optimisation.

Training with parameter-shift gradients

A variational quantum classifier has tunable rotation parameters. A loss function measures disagreement between its predictions and the class labels in the training dataset. For suitable parameterised gates, the parameter-shift rule computes an exact derivative of an expectation value by comparing circuit evaluations at shifted parameter angles, typically separated by a constant such as π/2 for standard Pauli-generated rotations. Gradient descent uses these derivatives to adjust the parameters. The simulation displays this learning process and tracks model loss and classification accuracy over epochs.

Interpreting the visualisation responsibly

Choose a circular or XOR target pattern, then adjust the number of re-uploading layers and watch whether the boundary better follows the training labels. Follow the Bloch-sphere path for a probe point to see how repeated encodings and rotations alter its final state. Compare loss with accuracy; lower loss does not always imply a higher held-out test score. This is a simulator of quantum circuit learning, not evidence that quantum computers currently outperform classical models on the same task. Noise, sample complexity and fair baselines remain crucial for claims of advantage.

Frequently Asked Questions

1. What is quantum data re-uploading?

Quantum data re-uploading is a circuit-design technique in which the same classical input features are encoded into a quantum state repeatedly across successive layers. Trainable quantum operations are interleaved between those encodings. This can make the model’s measured output depend on the input through a richer set of functions than a single encoding stage could provide. In the MySimulator classifier, two-dimensional data are repeatedly encoded onto one qubit while rotation parameters are trained to distinguish two classes.

2. How can one qubit classify two-dimensional data?

A single qubit can be prepared in a known state, rotated by gates whose angles depend on input coordinates and then measured. The probability or expectation of a chosen measurement provides a continuous score. A threshold converts that score into a predicted label. Repeating feature encodings and trainable rotations can shape the score differently across the input plane. The learning capacity is limited by circuit design and number of parameters, so the method should not be interpreted as solving arbitrary classification problems effortlessly.

3. What is the Bloch sphere in quantum machine learning?

The Bloch sphere is a geometric representation of a pure single-qubit state, with points on its surface corresponding to different state orientations apart from global phase. Quantum rotation gates move the state around the sphere, and measurement probabilities depend on the final orientation relative to a chosen axis. In a data re-uploading model, the input point and learned parameters control the sequence of rotations. Watching a probe point’s trajectory helps make an otherwise abstract gate sequence easier to understand.

4. Why do quantum classifiers use rotation gates?

Rotation gates provide a compact, parameterised way to transform qubit states. Input features can determine some rotation angles, while trainable angles are adjusted by an optimiser during learning. Because measurement probabilities depend on the complete sequence, changing an early angle can affect the final prediction. Rotations are also natural building blocks for variational circuits that can be simulated classically at small scale or implemented on suitable quantum hardware. The simulator uses them to expose the connection between circuit parameters and the evolving decision boundary.

5. What is the parameter-shift rule?

The parameter-shift rule is a method for evaluating derivatives of certain quantum expectation values with respect to gate parameters. For common rotations generated by Pauli operators, the derivative can be obtained from a difference between expectation values evaluated at two shifted parameter settings, with an appropriate scale factor. This avoids relying on a purely finite-difference approximation for those gates. A training algorithm can combine the resulting gradients with a classical optimiser. The simulator makes this hybrid quantum–classical learning loop visible as parameters change across epochs.

6. Can a quantum data re-uploading classifier learn XOR?

A sufficiently expressive re-uploading circuit can represent nonlinear patterns that are difficult for a simple linear decision boundary, including XOR-style arrangements. XOR assigns different labels to points according to combinations of two binary-like features, so no single straight line separates the typical pattern. Repeated feature encodings and trainable rotations can create a more complex boundary. Whether training succeeds depends on architecture, initialisation, optimisation and data distribution. The interactive XOR option demonstrates learning behaviour rather than a guarantee of perfect classification.

7. Why do additional data re-uploading layers help?

Each layer adds another opportunity for the classical input to influence the evolving quantum state while trainable gates reshape that response. Greater depth can represent more intricate input-dependent functions, which may improve a model’s fit to circles or XOR-like patterns. However, extra parameters increase optimisation complexity and computational cost, and noisy physical devices may suffer from deeper circuits. The useful question is whether another layer improves generalisation on appropriate data, not whether a model can always be made better simply by increasing depth.

8. What do loss and accuracy mean in a quantum classifier?

Loss is a numerical objective that penalises disagreement between predicted scores or probabilities and training labels; its form depends on the chosen model. Accuracy measures the fraction of predictions with the correct class label under a threshold. These quantities are related but not identical: a model can reduce loss while leaving its number of correct labels unchanged. The simulator’s training curves help learners follow both. Proper evaluation of any machine learning approach also requires separate validation or test data to detect overfitting.

9. Does this simulation prove quantum machine learning is faster than classical ML?

No. A single-qubit circuit can be simulated efficiently on an ordinary computer, and successful classification demonstrates a training mechanism rather than computational advantage. Establishing quantum advantage would require a clearly defined task, scalable complexity analysis, relevant hardware constraints and competitive classical baselines. Noise, input loading, circuit depth and measurement overhead can erase theoretical benefits. The educational value of this simulation is understanding feature encoding, parameterised circuits and quantum gradient calculation, not making a speedup claim.

10. How should I experiment with the quantum classifier?

Start with a simple dataset and few re-upload layers, then observe the initial boundary and training loss. Add layers one at a time and compare whether the boundary can represent the target geometry more faithfully. Switch to XOR and inspect how a selected point travels around the Bloch sphere through successive rotations. Repeat from different initial conditions to appreciate optimisation variability. Record loss and accuracy separately, and remember that training performance alone cannot establish reliable generalisation or any practical quantum computing advantage.

What did you find?

Add reproduction steps (optional)