basic programming for quantum machine learning with
play

Basic programming for quantum machine learning with Qiskit and - PowerPoint PPT Presentation

Basic programming for quantum machine learning with Qiskit and PennyLane NITheP Mini-school Amira Abbas 08/09/2020 Applications The universe Material science Finance Logistics Quantum machine learning Source: Maria Schuld and Francesco


  1. Basic programming for quantum machine learning with Qiskit and PennyLane NITheP Mini-school Amira Abbas 08/09/2020

  2. Applications The universe Material science Finance Logistics

  3. Quantum machine learning Source: Maria Schuld and Francesco Petruccione. Supervised learning with quantum computers . Vol. 17. Springer, 2018.

  4. Quantum open source foundation qosf.org

  5. Agenda An introduction to variational circuits

  6. Agenda An introduction to variational circuits A simple model

  7. Agenda An introduction to variational circuits A simple model Circuit optimisation

  8. Agenda An introduction to variational circuits A simple model Circuit optimisation Build the model with PennyLane

  9. Agenda An introduction to variational circuits A simple model Circuit optimisation Build the model with PennyLane Assume basic knowledge of quantum computing ! Previous mini-school: Daniel Park; Nielsen & Chuang - Quantum computation and quantum information

  10. f ( x ; θ )

  11. f ( x ; θ ) θ

  12. | f ( x ; θ ) ⟩ θ

  13. Quantum models

  14. Quantum models Deterministic quantum models y | ψ ⟩ U Deutsch-Jozsa algorithm

  15. Quantum models Deterministic quantum models y | ψ ⟩ U Deutsch-Jozsa algorithm Variational quantum models Variational quantum eigensolver Variational quantum classifier | ψ ⟩ ⟨ y ⟩ U ( θ ) Quantum support vector machines Quantum neural networks

  16. Quantum machine learning . . .

  17. Quantum machine learning U ( x ; θ ) . . .

  18. Quantum machine learning U ( x ; θ ) . . . | f ( x ; θ ) ⟩

  19. Quantum machine learning M U ( x ; θ ) . . . | f ( x ; θ ) ⟩

  20. ̂ M } Quantum machine learning y U ( x ; θ ) . . . | f ( x ; θ ) ⟩

  21. Variational circuits

  22. Success of variational models Can run on near term quantum hardware Robust to noise Shows most promise in chemistry applications Can be used in many quantum machine learning models

  23. A simple example | 0 ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  24. A simple example | 0 ⟩ | 0 ⟩ = [ 0 ] 1 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  25. A simple example | 0 ⟩ | 0 ⟩ = [ 0 ] 1 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  26. A simple example | 0 ⟩ ⟨ σ z ⟩ | 0 ⟩ = [ 0 ] 1 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  27. A simple example | 0 ⟩ ⟨ σ z ⟩ | 0 ⟩ = [ σ z = [ 0 ] 0 − 1 ] 1 1 0 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  28. A simple example | 0 ⟩ ⟨ σ z ⟩ | 0 ⟩ = [ σ z = [ 0 ] 0 − 1 ] 1 1 0 Calculating the expectation value: ⟨ 0 ∣ σ z ∣ 0 ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  29. A simple example | 0 ⟩ ⟨ σ z ⟩ | 0 ⟩ = [ σ z = [ 0 ] 0 − 1 ] 1 1 0 0] [ − 1 ] [ 0 ] 1 0 1 Calculating the expectation value: ⟨ 0 ∣ σ z ∣ 0 ⟩ = [1 0 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  30. A simple example | 0 ⟩ ⟨ σ z ⟩ | 0 ⟩ = [ σ z = [ 0 ] 0 − 1 ] 1 1 0 0] [ − 1 ] [ 0 ] = 1 1 0 1 Calculating the expectation value: ⟨ 0 ∣ σ z ∣ 0 ⟩ = [1 0 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  31. A simple example | 0 ⟩ X ⟨ σ z ⟩ X = [ | 0 ⟩ = [ σ z = [ 0 ] 0 ] 0 − 1 ] 0 1 1 1 0 1 Calculating the expectation value: ⟨ 1 ∣ σ z ∣ 1 ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  32. A simple example | 0 ⟩ X ⟨ σ z ⟩ X = [ | 0 ⟩ = [ σ z = [ 0 ] 0 ] 0 − 1 ] 0 1 1 1 0 1 1] [ − 1 ] [ 1 ] = − 1 1 0 0 Calculating the expectation value: ⟨ 1 ∣ σ z ∣ 1 ⟩ = [0 0 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  33. A simple example | 0 ⟩ ⊗ n U ( θ )

  34. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  35. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  36. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 State after operations: | ψ ⟩ = R y ( θ 2 ) R x ( θ 1 ) | 0 ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  37. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 State after operations: | ψ ⟩ = R y ( θ 2 ) R x ( θ 1 ) | 0 ⟩ Calculating the expectation value: ⟨ ψ ∣ σ z ∣ ψ ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  38. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 State after operations: | ψ ⟩ = R y ( θ 2 ) R x ( θ 1 ) | 0 ⟩ Calculating the expectation value: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  39. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 State after operations: | ψ ⟩ = R y ( θ 2 ) R x ( θ 1 ) | 0 ⟩ Calculating the expectation value: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  40. A simple example | 0 ⟩ ⟨ σ z ⟩ R x ( θ 1 ) R y ( θ 2 ) θ 1 θ 1 θ 2 θ 2 | 0 ⟩ = [ σ z = [ − i sin − sin cos cos 0 ] − 1 ] 1 0 1 2 2 2 2 R x ( θ 1 ) = R y ( θ 2 ) = θ 1 θ 1 θ 2 θ 2 0 − i sin cos sin cos 2 2 2 2 State after operations: | ψ ⟩ = R y ( θ 2 ) R x ( θ 1 ) | 0 ⟩ Calculating the expectation value: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) How do we choose the parameters? Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  41. A simple example | 0 ⟩ ⊗ n U ( θ )

  42. ̂ A simple example | 0 ⟩ ⊗ n y U ( θ )

  43. ̂ A simple example | 0 ⟩ ⊗ n y U ( θ ) cost

  44. ̂ A simple example | 0 ⟩ ⊗ n y U ( θ ) update θ cost

  45. ̂ Classical machine learning y σ ( f ( θ )) f ( θ ) data update θ cost

  46. A simple example Define a cost function which we want to minimise: Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  47. A simple example Define a cost function which we want to minimise: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  48. A simple example Define a cost function which we want to minimise: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) [ 0 − 1 ] [ 0 ] = 1 [1 0] 1 0 1 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  49. A simple example Define a cost function which we want to minimise: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) [ 0 − 1 ] [ 0 ] = 1 [1 0] 1 0 1 [ 0 − 1 ] [ 1 ] = − 1 [0 1] 1 0 0 Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  50. A simple example Define a cost function which we want to minimise: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 ) Source:https://pennylane.ai/qml/demos/tutorial_qubit_rotation.html

  51. Circuit optimisation

  52. Circuit optimisation Define a cost function: ⟨ ψ ∣ σ z ∣ ψ ⟩ = ⟨ 0 ∣ R x ( θ 1 ) † Ry ( θ 2 ) † σ z R y ( θ 2 ) R x ( θ 1 ) ∣ 0 ⟩ = cos( θ 1 ) cos( θ 2 )

  53. Gradient-based methods

  54. Gradient descent

  55. ⃗ Gradient descent cost θ

  56. ⃗ Gradient descent cost θ 1 θ

  57. ⃗ Gradient descent cost θ 1 θ

  58. ⃗ Gradient descent cost θ 1 θ

  59. ⃗ Gradient descent cost θ * θ 1 θ 2 θ

  60. ̂ Gradient-based methods | 0 ⟩ ⊗ n y θ U ( θ ) Source:Schuld, Maria, et al. "Circuit-centric quantum classifiers." Physical Review A 101.3 (2020): 032308.

Recommend


More recommend