qxmt.feature_maps.pennylane package#
Submodules#
qxmt.feature_maps.pennylane.rotation module#
- class qxmt.feature_maps.pennylane.rotation.HRotationFeatureMap(n_qubits, reps, rotation_axis)#
Bases:
BaseFeatureMap
Hadamard and multi-axis rotation feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
rotation_axis (list[str])
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.rotation import HRotationFeatureMap >>> feature_map = HRotationFeatureMap(2, 2, ["X", "Y"]) >>> feature_map.draw(x_dim=2) 0: ──H─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)──H─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─┤ 1: ──H─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)──H─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─┤ M0 = [0.88859928 0.32907378]
- __init__(n_qubits, reps, rotation_axis)#
Initialize the Hadamard and multi axis rotation feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
rotation_axis (list[str]) – list of rotation axis
- Return type:
None
- feature_map(x)#
Create quantum circuit of Hadamard and rotation feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.rotation.RotationFeatureMap(n_qubits, reps, rotation_axis)#
Bases:
BaseFeatureMap
Multi-axis rotation feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
rotation_axis (list[str])
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.rotation import RotationFeatureMap >>> feature_map = RotationFeatureMap(2, 2, ["X", "Y"]) >>> feature_map.draw(x_dim=2) 0: ─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─┤ 1: ─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─┤ M0 = [0.87336112 0.05976227]
- __init__(n_qubits, reps, rotation_axis)#
Initialize the multi axis rotation feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
rotation_axis (list[str]) – list of rotation axis
- Return type:
None
- feature_map(x)#
Create quantum circuit of rotation feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
qxmt.feature_maps.pennylane.ising module#
- class qxmt.feature_maps.pennylane.ising.XXFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
XX feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import XXFeatureMap >>> feature_map = XXFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──RX(0.33)─╭IsingXX(15.19)──RX(0.33)─╭IsingXX(15.19)─┤ 1: ──RX(0.44)─╰IsingXX(15.19)──RX(0.44)─╰IsingXX(15.19)─┤
- __init__(n_qubits, reps)#
Initialize the XX feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of XX feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.ising.YYFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
YY feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import YYFeatureMap >>> feature_map = YYFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──H──RY(0.86)─╭IsingYY(11.23)──H──RY(0.86)─╭IsingYY(11.23)─┤ 1: ──H──RY(0.68)─╰IsingYY(11.23)──H──RY(0.68)─╰IsingYY(11.23)─┤
- __init__(n_qubits, reps)#
Initialize the YY feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of YY feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.ising.ZZFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
ZZ feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import ZZFeatureMap >>> feature_map = ZZFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──H──RZ(0.88)─╭IsingZZ(13.28)──H──RZ(0.88)─╭IsingZZ(13.28)─┤ 1: ──H──RZ(0.20)─╰IsingZZ(13.28)──H──RZ(0.20)─╰IsingZZ(13.28)─┤
- __init__(n_qubits, reps)#
Initialize the ZZ feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of ZZ feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
qxmt.feature_maps.pennylane.npqc module#
- class qxmt.feature_maps.pennylane.npqc.NPQCFeatureMap(n_qubits, reps, c)#
Bases:
BaseFeatureMap
NPQC feature map class. Reference: https://arxiv.org/abs/2108.01039
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
c (float)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.npqc import NPQCFeatureMap >>> feature_map = NPQCFeatureMap(2, 2, 0.1) >>> feature_map.draw(x_dim=2) 0: ──RY(1.60)──RZ(1.59)──RY(1.57)─╭●──RY(1.60)──RZ(1.59)──RY(1.57)─╭●──RY(1.60)─┤ 1: ──RY(1.60)──RZ(1.59)───────────╰Z───────────────────────────────╰Z───────────┤
- __init__(n_qubits, reps, c)#
“Initialize the NPQC feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
c (float) – scaling factor
seed (int) – random seed
- Return type:
None
- feature_map(x)#
Create quantum circuit of NPQC feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
qxmt.feature_maps.pennylane.yzcx module#
- class qxmt.feature_maps.pennylane.yzcx.YZCXFeatureMap(n_qubits, reps, c, seed)#
Bases:
BaseFeatureMap
YZCX feature map class. Reference: https://arxiv.org/abs/2108.01039
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
c (float)
seed (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.yzcx import YZCXFeatureMap >>> feature_map = YZCXFeatureMap(2, 2, 0.1, 0) >>> feature_map.draw(x_dim=2) 0: ──RY(0.03)──RY(3.42)──RZ(0.05)──RZ(5.88)─╭●──RY(0.03)──RY(5.39)──RZ(0.05)──RZ(0.21) 1: ─────────────────────────────────────────╰X──RY(0.03)──RY(5.13)──RZ(0.05)──RZ(0.02) ──────────────────────────────────────────┤ ──RY(0.03)───RY(4.58)──RZ(0.05)──RZ(1.10)─┤
- __init__(n_qubits, reps, c, seed)#
“Initialize the YZCX feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
c (float) – scaling factor
seed (int) – random seed
- Return type:
None
- feature_map(x)#
Create quantum circuit of YZCX feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
Module contents#
- class qxmt.feature_maps.pennylane.HRotationFeatureMap(n_qubits, reps, rotation_axis)#
Bases:
BaseFeatureMap
Hadamard and multi-axis rotation feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
rotation_axis (list[str])
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.rotation import HRotationFeatureMap >>> feature_map = HRotationFeatureMap(2, 2, ["X", "Y"]) >>> feature_map.draw(x_dim=2) 0: ──H─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)──H─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─┤ 1: ──H─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)──H─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─┤ M0 = [0.88859928 0.32907378]
- __init__(n_qubits, reps, rotation_axis)#
Initialize the Hadamard and multi axis rotation feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
rotation_axis (list[str]) – list of rotation axis
- Return type:
None
- feature_map(x)#
Create quantum circuit of Hadamard and rotation feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.NPQCFeatureMap(n_qubits, reps, c)#
Bases:
BaseFeatureMap
NPQC feature map class. Reference: https://arxiv.org/abs/2108.01039
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
c (float)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.npqc import NPQCFeatureMap >>> feature_map = NPQCFeatureMap(2, 2, 0.1) >>> feature_map.draw(x_dim=2) 0: ──RY(1.60)──RZ(1.59)──RY(1.57)─╭●──RY(1.60)──RZ(1.59)──RY(1.57)─╭●──RY(1.60)─┤ 1: ──RY(1.60)──RZ(1.59)───────────╰Z───────────────────────────────╰Z───────────┤
- __init__(n_qubits, reps, c)#
“Initialize the NPQC feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
c (float) – scaling factor
seed (int) – random seed
- Return type:
None
- feature_map(x)#
Create quantum circuit of NPQC feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.RotationFeatureMap(n_qubits, reps, rotation_axis)#
Bases:
BaseFeatureMap
Multi-axis rotation feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
rotation_axis (list[str])
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.rotation import RotationFeatureMap >>> feature_map = RotationFeatureMap(2, 2, ["X", "Y"]) >>> feature_map.draw(x_dim=2) 0: ─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─╭AngleEmbedding(M0)─┤ 1: ─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─╰AngleEmbedding(M0)─┤ M0 = [0.87336112 0.05976227]
- __init__(n_qubits, reps, rotation_axis)#
Initialize the multi axis rotation feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
rotation_axis (list[str]) – list of rotation axis
- Return type:
None
- feature_map(x)#
Create quantum circuit of rotation feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.XXFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
XX feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import XXFeatureMap >>> feature_map = XXFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──RX(0.33)─╭IsingXX(15.19)──RX(0.33)─╭IsingXX(15.19)─┤ 1: ──RX(0.44)─╰IsingXX(15.19)──RX(0.44)─╰IsingXX(15.19)─┤
- __init__(n_qubits, reps)#
Initialize the XX feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of XX feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.YYFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
YY feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import YYFeatureMap >>> feature_map = YYFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──H──RY(0.86)─╭IsingYY(11.23)──H──RY(0.86)─╭IsingYY(11.23)─┤ 1: ──H──RY(0.68)─╰IsingYY(11.23)──H──RY(0.68)─╰IsingYY(11.23)─┤
- __init__(n_qubits, reps)#
Initialize the YY feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of YY feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.YZCXFeatureMap(n_qubits, reps, c, seed)#
Bases:
BaseFeatureMap
YZCX feature map class. Reference: https://arxiv.org/abs/2108.01039
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
c (float)
seed (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.yzcx import YZCXFeatureMap >>> feature_map = YZCXFeatureMap(2, 2, 0.1, 0) >>> feature_map.draw(x_dim=2) 0: ──RY(0.03)──RY(3.42)──RZ(0.05)──RZ(5.88)─╭●──RY(0.03)──RY(5.39)──RZ(0.05)──RZ(0.21) 1: ─────────────────────────────────────────╰X──RY(0.03)──RY(5.13)──RZ(0.05)──RZ(0.02) ──────────────────────────────────────────┤ ──RY(0.03)───RY(4.58)──RZ(0.05)──RZ(1.10)─┤
- __init__(n_qubits, reps, c, seed)#
“Initialize the YZCX feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
c (float) – scaling factor
seed (int) – random seed
- Return type:
None
- feature_map(x)#
Create quantum circuit of YZCX feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None
- class qxmt.feature_maps.pennylane.ZZFeatureMap(n_qubits, reps)#
Bases:
BaseFeatureMap
ZZ feature map class.
- Parameters:
BaseFeatureMap (_type_) – base feature map class
n_qubits (int)
reps (int)
Example
>>> import numpy as np >>> from qxmt.feature_maps.pennylane.ising import ZZFeatureMap >>> feature_map = ZZFeatureMap(2, 2) >>> feature_map.draw(x_dim=2) 0: ──H──RZ(0.88)─╭IsingZZ(13.28)──H──RZ(0.88)─╭IsingZZ(13.28)─┤ 1: ──H──RZ(0.20)─╰IsingZZ(13.28)──H──RZ(0.20)─╰IsingZZ(13.28)─┤
- __init__(n_qubits, reps)#
Initialize the ZZ feature map class.
- Parameters:
n_qubits (int) – number of qubits
reps (int) – number of repetitions
- Return type:
None
- feature_map(x)#
Create quantum circuit of ZZ feature map.
- Parameters:
x (np.ndarray) – input data
- Return type:
None