Skip to main contentIBM Quantum Documentation
This page is from the dev version of Qiskit SDK. Go to the stable version

zz_feature_map

class 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')

GitHub

Bases:

Second-order Pauli-Z evolution circuit.

For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:

┌───┐┌────────────────┐
┤ 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 φ(x)=x\varphi(x) = x if and φ(x,y)=(πx)(πy)\varphi(x,y) = (\pi - x)(\pi - y).

Examples

>>> 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 ├
     └───┘└─────────────┘└───┘└────────────────────────────────┘└───┘
>>> 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

Return type

QuantumCircuit

Was this page helpful?
Report a bug or request content on GitHub.