About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
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')
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 is a classical non-linear function, which defaults to if and .
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
- feature_dimension (int) –
- reps (int) –
- entanglement (str | Sequence[Sequence[int]] | Callable[[int], str | Sequence[Sequence[int]]]) –
- alpha (float) –
- data_map_func (Callable[[Parameter], ParameterExpression] | None) –
- parameter_prefix (str) –
- insert_barriers (bool) –
- name (str) –
Return type
Was this page helpful?
Report a bug or request content on GitHub.