Skip to main content
IBM Quantum Platform

ZFeatureMap

class qiskit.circuit.library.ZFeatureMap(feature_dimension, reps=2, data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZFeatureMap')

GitHub

ベース: PauliFeatureMap

1次のパウリZ進化回路。

3量子ビットで2回の繰り返しの場合、回路は次のように表される:

┌───┐┌─────────────┐┌───┐┌─────────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ H ├┤ P(2.0*x[0]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ P(2.0*x[1]) ├┤ H ├┤ P(2.0*x[1]) ├
├───┤├─────────────┤├───┤├─────────────┤
┤ H ├┤ P(2.0*x[2]) ├┤ H ├┤ P(2.0*x[2]) ├
└───┘└─────────────┘└───┘└─────────────┘

これは、 PauliFeatureMap ここで、パウリ弦は ['Z'] に固定されています。 その結果、1次拡張はもつれゲートのない回路となる。

>>> prep = ZFeatureMap(3, reps=3, insert_barriers=True)
>>> print(prep.decompose())
     ┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐ ░ ┌───┐ ░ ┌─────────────┐
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])
     └───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘ ░ └───┘ ░ └─────────────┘
>>> data_map = lambda x: x[0]*x[0] + 1  # note: input is an array
>>> prep = ZFeatureMap(3, reps=1, data_map_func=data_map)
>>> print(prep.decompose())
     ┌───┐┌──────────────────────┐
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)
     └───┘└──────────────────────┘
>>> from qiskit.circuit.library import TwoLocal
>>> ry = TwoLocal(3, "ry", "cz", reps=1)
>>> classifier = ZFeatureMap(3, reps=1) + ry
>>> print(classifier.decompose())
     ┌───┐┌─────────────┐┌──────────┐      ┌──────────┐
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])
     └───┘└─────────────┘└──────────┘                  └──────────┘
バージョンから非推奨 2.1

クラス qiskit.circuit.library.data_preparation._z_feature_map.ZFeatureMap は Qiskit 2.1 で非推奨となりました。 Qiskit 3.0 で削除されます。 z_feature_map関数を代替として使用する。 これはもはや BlueprintCircuit, を返すのではなく、単なる QuantumCircuit を返すことに注意してください。

パラメーター

  • feature_dimension (int) – 機能の数
  • reps (int) – 繰り返される回路の数。 デフォルトは2で、最小値は1。
  • data_map_func (Callable[[ndarray], float] | None) – データ x に対するマッピング関数。これを指定することで、のデフォルトのマッピング self_product()を上書きできます。
  • parameter_prefix (str) – デフォルトのパラメータが生成される場合に使用する接頭辞。
  • insert_barriers (bool) – Trueの場合、進化命令とハダマード層の間にバリアが挿入される。
  • name (str) – 回路名。

属性

name

タイプ: str

人間が読める回路名。

from qiskit import QuantumCircuit

qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
my_circuit
このページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。