Skip to content

Commit

Permalink
Add example to AngleEmbedding (#1908)
Browse files Browse the repository at this point in the history
* Update angle.py

Add example in documentation

* Update angle.py

reformat

* Apply suggestions from code review

Co-authored-by: antalszava <antalszava@gmail.com>

* Update changelog-dev.md

Co-authored-by: antalszava <antalszava@gmail.com>
  • Loading branch information
ankit27kh and antalszava committed Nov 17, 2021
1 parent 80a169d commit b74f892
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@
* Improves the Developer's Guide Testing document.
[(#1896)](https://github.com/PennyLaneAI/pennylane/pull/1896)

* Added documentation example for AngleEmbedding.
[(#1908)](https://github.com/PennyLaneAI/pennylane/pull/1908)

<h3>Contributors</h3>

This release contains contributions from (in alphabetical order):

Guillermo Alonso-Linaje, Benjamin Cordier, Olivia Di Matteo, Jalani Kanem, Ankit Khandelwal, Shumpei Kobayashi,
Christina Lee, Alejandro Montanez, Romain Moyard, Maria Schuld, Jay Soni, David Wierichs
Christina Lee, Alejandro Montanez, Romain Moyard, Maria Schuld, Jay Soni, David Wierichs
25 changes: 25 additions & 0 deletions pennylane/templates/embeddings/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,31 @@ class AngleEmbedding(Operation):
with :math:`N\leq n`
wires (Iterable): wires that the template acts on
rotation (str): type of rotations used
Example:
Angle embedding encodes the features by using the specified rotation operation.
.. code-block:: python
dev = qml.device('default.qubit', wires=3)
@qml.qnode(dev)
def circuit(feature_vector):
qml.AngleEmbedding(features=feature_vector, wires=range(3), rotation='Z')
qml.Hadamard(0)
return qml.probs(wires=range(3))
X = [1,2,3]
Here, we have also used rotation angles :class:`RZ`. If not specified, :class:`RX` is used as default.
The resulting circuit is:
>>> print(qml.draw(circuit)(X))
0: ──RZ(1)──H──╭┤ Probs
1: ──RZ(2)─────├┤ Probs
2: ──RZ(3)─────╰┤ Probs
"""

num_wires = AnyWires
Expand Down

0 comments on commit b74f892

Please sign in to comment.