ZZFeatureMap
class qiskit.circuit.library.ZZFeatureMap(feature_dimension, reps=2, entanglement='full', data_map_func=None, parameter_prefix='x', insert_barriers=False, name='ZZFeatureMap')
ベース: PauliFeatureMap
2次のパウリ-Z進化回路。
3量子ビット、1反復、線形エンタングルメントの場合、回路は次のように表される:
┌───┐┌────────────────┐
┤ 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 ├
└───┘└────────────────┘ └───┘└─────────────────────┘└───┘ここで、 は古典的な非線形関数であり、 の場合はデフォルトで となり、 の場合は となる。また、 は、特徴マップ内の接続を表す量子ビットのインデックスの集合である。 詳細については、 pauli_feature_map() のdocstringを参照してください。
例:
from qiskit.circuit.library import ZZFeatureMap
prep = ZZFeatureMap(2, reps=1)
print(prep.decompose()) ┌───┐┌─────────────┐
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 ├
└───┘└─────────────┘└───┘└────────────────────────────────┘└───┘from qiskit.circuit.library import EfficientSU2
classifier = ZZFeatureMap(3).compose(EfficientSU2(3))
classifier.num_parameters27classifier.parameters # 'x' for the data preparation, 'θ' for the SU2 parametersParameterView([
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])
])classifier.count_ops()OrderedDict([('ZZFeatureMap', 1), ('EfficientSU2', 1)])バージョンから非推奨 2.1
クラス qiskit.circuit.library.data_preparation._zz_feature_map.ZZFeatureMap は Qiskit 2.1 で非推奨となりました。 Qiskit 3.0 で削除されます。 代替としてzz_feature_map関数を使用する。 これはもはや BlueprintCircuit, を返すのではなく、単なる QuantumCircuit を返すことに注意してください。
パラメーター
- feature_dimension (int) – 機能の数。
- reps (int) – 繰り返される回路の数で、最小値は1。
- entanglement (str |dict[int, list[tuple[int]]] | Callable[[int], str |dict[int, list[tuple[int]]]]) – エンタングルメント構造を指定します。 詳細は をご覧ください
PauliFeatureMap。 - data_map_func (Callable[[ndarray], float] | None) – データに対する
x写像関数。 - parameter_prefix (str) – デフォルトのパラメータが生成される場合に使用する接頭辞。
- insert_barriers (bool) – その場合
True、進化指令とハダマール層の間に障壁が挿入される。 - name (str) – 回路名。
レイズ
ValueError - 特徴次元が2より小さい場合。
属性
name
タイプ: str
人間が読める回路名。
例
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)my_circuitこのページは役に立ちましたか?
バグや誤字の報告、またはコンテンツの要求はGitHubで行ってください。