Editing
Quantum Machine Learning
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Variational quantum classifier with PennyLane:''' <syntaxhighlight lang="python"> import pennylane as qml import numpy as np from pennylane import numpy as pnp n_qubits = 4 dev = qml.device("default.qubit", wires=n_qubits) def angle_embedding(x): """Encode classical data as qubit rotation angles.""" for i, val in enumerate(x[:n_qubits]): qml.RY(val, wires=i) def variational_layer(weights): """Trainable quantum layer.""" for i in range(n_qubits): qml.RY(weights[i, 0], wires=i) qml.RZ(weights[i, 1], wires=i) # Entanglement for i in range(n_qubits - 1): qml.CNOT(wires=[i, i + 1]) @qml.qnode(dev, diff_method="parameter-shift") def quantum_classifier(x, weights): angle_embedding(x) for layer_weights in weights: variational_layer(layer_weights) return qml.expval(qml.PauliZ(0)) # Measurement: expectation value # Training (gradient via parameter-shift rule) n_layers = 3 weights = pnp.random.randn(n_layers, n_qubits, 2, requires_grad=True) opt = qml.AdamOptimizer(stepsize=0.1) def cost(weights, X_batch, y_batch): preds = pnp.array([quantum_classifier(x, weights) for x in X_batch]) return pnp.mean((preds - y_batch) ** 2) </syntaxhighlight> ; QML approach landscape : '''Current hardware (NISQ)''' β VQE for chemistry, QAOA for optimization, PQC classifiers : '''Quantum annealing''' β D-Wave systems for combinatorial optimization (routing, scheduling) : '''Quantum kernel SVM''' β Quantum feature maps + classical SVM kernel trick : '''Future (fault-tolerant)''' β HHL for linear algebra, Grover for search, quantum PCA : '''Hybrid classical-quantum''' β Quantum layers in PyTorch (TorchScript via PennyLane/Qiskit) </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information