85 lines
5.8 KiB
Plaintext
85 lines
5.8 KiB
Plaintext
---
|
||
title: zz_feature_map (latest version)
|
||
description: API reference for qiskit.circuit.library.zz_feature_map in the latest version of qiskit
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.circuit.library.zz_feature_map
|
||
---
|
||
|
||
<span id="zz-feature-map" />
|
||
|
||
# zz\_feature\_map
|
||
|
||
<Class id="qiskit.circuit.library.zz_feature_map" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L249-L321" signature="qiskit.circuit.library.zz_feature_map(feature_dimension, reps=2, entanglement='full', alpha=2.0, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZZFeatureMap')" modifiers="class">
|
||
Bases:
|
||
|
||
Second-order Pauli-Z evolution circuit.
|
||
|
||
For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:
|
||
|
||
```text
|
||
┌───┐┌────────────────┐
|
||
┤ H ├┤ P(2.0*φ(x[0])) ├──■───────────────────────────■───────────────────────────────────
|
||
├───┤├────────────────┤┌─┴─┐┌─────────────────────┐┌─┴─┐
|
||
┤ H ├┤ P(2.0*φ(x[1])) ├┤ X ├┤ P(2.0*φ(x[0],x[1])) ├┤ X ├──■───────────────────────────■──
|
||
├───┤├────────────────┤└───┘└─────────────────────┘└───┘┌─┴─┐┌─────────────────────┐┌─┴─┐
|
||
┤ H ├┤ P(2.0*φ(x[2])) ├─────────────────────────────────┤ X ├┤ P(2.0*φ(x[1],x[2])) ├┤ X ├
|
||
└───┘└────────────────┘ └───┘└─────────────────────┘└───┘
|
||
```
|
||
|
||
where $\varphi$ is a classical non-linear function, which defaults to $\varphi(x) = x$ if and $\varphi(x,y) = (\pi - x)(\pi - y)$.
|
||
|
||
**Examples**
|
||
|
||
```python
|
||
>>> from qiskit.circuit.library import ZZFeatureMap
|
||
>>> prep = zz_feature_map(2, reps=1)
|
||
>>> print(prep)
|
||
┌───┐┌─────────────┐
|
||
q_0: ┤ H ├┤ P(2.0*x[0]) ├──■──────────────────────────────────────■──
|
||
├───┤├─────────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
|
||
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ X ├┤ P(2.0*(pi - x[0])*(pi - x[1])) ├┤ X ├
|
||
└───┘└─────────────┘└───┘└────────────────────────────────┘└───┘
|
||
```
|
||
|
||
```python
|
||
>>> from qiskit.circuit.library import EfficientSU2
|
||
>>> classifier = zz_feature_map(3) + EfficientSU2(3)
|
||
>>> classifier.num_parameters
|
||
15
|
||
>>> classifier.parameters # 'x' for the data preparation, 'θ' for the SU2 parameters
|
||
ParameterView([
|
||
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
|
||
ParameterVectorElement(x[2]), ParameterVectorElement(θ[0]),
|
||
ParameterVectorElement(θ[1]), ParameterVectorElement(θ[2]),
|
||
ParameterVectorElement(θ[3]), ParameterVectorElement(θ[4]),
|
||
ParameterVectorElement(θ[5]), ParameterVectorElement(θ[6]),
|
||
ParameterVectorElement(θ[7]), ParameterVectorElement(θ[8]),
|
||
ParameterVectorElement(θ[9]), ParameterVectorElement(θ[10]),
|
||
ParameterVectorElement(θ[11]), ParameterVectorElement(θ[12]),
|
||
ParameterVectorElement(θ[13]), ParameterVectorElement(θ[14]),
|
||
ParameterVectorElement(θ[15]), ParameterVectorElement(θ[16]),
|
||
ParameterVectorElement(θ[17]), ParameterVectorElement(θ[18]),
|
||
ParameterVectorElement(θ[19]), ParameterVectorElement(θ[20]),
|
||
ParameterVectorElement(θ[21]), ParameterVectorElement(θ[22]),
|
||
ParameterVectorElement(θ[23])
|
||
])
|
||
```
|
||
|
||
**Parameters**
|
||
|
||
* **feature\_dimension** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) –
|
||
* **reps** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) –
|
||
* **entanglement** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *| Sequence\[Sequence\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]] | Callable\[\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*],* [*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *| Sequence\[Sequence\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*]]]*) –
|
||
* **alpha** ([*float*](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")) –
|
||
* **data\_map\_func** (*Callable\[\[*[*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*],* [*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")*] | None*) –
|
||
* **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) –
|
||
* **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) –
|
||
* **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) –
|
||
|
||
**Return type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Class>
|
||
|