BasicEntanglerAnsatz#
- class pyqit.ansatzes.BasicEntanglerAnsatz(n_qubits: int, n_layers: int = 2, rotation=None)[source]#
Bases:
BaseAnsatzBasic entangler layers: one rotation per qubit and a CNOT ring per layer.
Wraps PennyLane’s BasicEntanglerLayers (Schuld et al. 2020 lineage). The weights are one tensor, weights, of shape (n_layers, n_qubits).
- Parameters:
n_qubits (int)
n_layers (int, default 2)
rotation (type, optional) – Single-qubit rotation gate class. PennyLane’s default is qml.RX.
Examples
>>> import pennylane as qml >>> from pyqit.ansatzes import BasicEntanglerAnsatz >>> ansatz = BasicEntanglerAnsatz(n_qubits=4, n_layers=2, rotation=qml.RY) >>> ansatz.get_weight_shapes() {'weights': (2, 4)}
- build_circuit(weights)[source]#
Apply the layers. Expects weights[“weights”] of shape (n_layers, n_qubits).
- get_circuit_func()#
Returns the bound method to be passed to a QNode.