89 lines
6.4 KiB
Plaintext
89 lines
6.4 KiB
Plaintext
---
|
||
title: z_feature_map (latest version)
|
||
description: API reference for qiskit.circuit.library.z_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.z_feature_map
|
||
---
|
||
|
||
<span id="z-feature-map" />
|
||
|
||
# z\_feature\_map
|
||
|
||
<Class id="qiskit.circuit.library.z_feature_map" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/circuit/library/data_preparation/pauli_feature_map.py#L170-L246" signature="qiskit.circuit.library.z_feature_map(feature_dimension, reps=2, entanglement='full', alpha=2.0, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZFeatureMap')" modifiers="class">
|
||
Bases:
|
||
|
||
The first order Pauli Z-evolution circuit.
|
||
|
||
On 3 qubits and with 2 repetitions the circuit is represented by:
|
||
|
||
```text
|
||
┌───┐┌─────────────┐┌───┐┌─────────────┐
|
||
┤ H ├┤ P(2.0*x[0]) ├┤ H ├┤ P(2.0*x[0]) ├
|
||
├───┤├─────────────┤├───┤├─────────────┤
|
||
┤ H ├┤ U(2.0*x[1]) ├┤ H ├┤ P(2.0*x[1]) ├
|
||
├───┤├─────────────┤├───┤├─────────────┤
|
||
┤ H ├┤ P(2.0*x[2]) ├┤ H ├┤ P(2.0*x[2]) ├
|
||
└───┘└─────────────┘└───┘└─────────────┘
|
||
```
|
||
|
||
This is a sub-class of [`PauliFeatureMap`](qiskit.circuit.library.PauliFeatureMap "qiskit.circuit.library.PauliFeatureMap") where the Pauli strings are fixed as \[‘Z’]. As a result the first order expansion will be a circuit without entangling gates.
|
||
|
||
**Examples**
|
||
|
||
```python
|
||
>>> prep = z_feature_map(3, reps=3, insert_barriers=True)
|
||
>>> print(prep)
|
||
┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐
|
||
q_0: ┤ H ├─░─┤ P(2.0*x[0]) ├─░─┤ H ├─░─┤ P(2.0*x[0]) ├─░─┤ H ├─░─┤ P(2.0*x[0]) ├
|
||
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
|
||
q_1: ┤ H ├─░─┤ P(2.0*x[1]) ├─░─┤ H ├─░─┤ P(2.0*x[1]) ├─░─┤ H ├─░─┤ P(2.0*x[1]) ├
|
||
├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤ ░ ├───┤ ░ ├─────────────┤
|
||
q_2: ┤ H ├─░─┤ P(2.0*x[2]) ├─░─┤ H ├─░─┤ P(2.0*x[2]) ├─░─┤ H ├─░─┤ P(2.0*x[2]) ├
|
||
└───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘
|
||
```
|
||
|
||
```python
|
||
>>> data_map = lambda x: x[0]*x[0] + 1 # note: input is an array
|
||
>>> prep = z_feature_map(3, reps=1, data_map_func=data_map)
|
||
>>> print(prep)
|
||
┌───┐┌──────────────────────┐
|
||
q_0: ┤ H ├┤ P(2.0*x[0]**2 + 2.0) ├
|
||
├───┤├──────────────────────┤
|
||
q_1: ┤ H ├┤ P(2.0*x[1]**2 + 2.0) ├
|
||
├───┤├──────────────────────┤
|
||
q_2: ┤ H ├┤ P(2.0*x[2]**2 + 2.0) ├
|
||
└───┘└──────────────────────┘
|
||
```
|
||
|
||
```python
|
||
>>> from qiskit.circuit.library import TwoLocal
|
||
>>> ry = TwoLocal(3, "ry", "cz", reps=1).decompose()
|
||
>>> classifier = z_feature_map(3, reps=1) + ry
|
||
>>> print(classifier)
|
||
┌───┐┌─────────────┐┌──────────┐ ┌──────────┐
|
||
q_0: ┤ H ├┤ P(2.0*x[0]) ├┤ RY(θ[0]) ├─■──■─┤ RY(θ[3]) ├────────────
|
||
├───┤├─────────────┤├──────────┤ │ │ └──────────┘┌──────────┐
|
||
q_1: ┤ H ├┤ P(2.0*x[1]) ├┤ RY(θ[1]) ├─■──┼──────■──────┤ RY(θ[4]) ├
|
||
├───┤├─────────────┤├──────────┤ │ │ ├──────────┤
|
||
q_2: ┤ H ├┤ P(2.0*x[2]) ├┤ RY(θ[2]) ├────■──────■──────┤ RY(θ[5]) ├
|
||
└───┘└─────────────┘└──────────┘ └──────────┘
|
||
```
|
||
|
||
**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>
|
||
|