SELAnsatz#

class pyqit.ansatzes.SELAnsatz(n_qubits: int, n_layers: int = 2)[source]#

Bases: BaseAnsatz

Strongly entangling layers of Schuld et al. (2020).

Wraps PennyLane’s StronglyEntanglingLayers. Each layer applies three rotations to every qubit, then a CNOT layer whose range grows with the layer index. The weights are one tensor, weights, of shape (n_layers, n_qubits, 3).

Parameters:
  • n_qubits (int)

  • n_layers (int, default 2)

References

Schuld, Bocharov, Svore, Wiebe, “Circuit-centric quantum classifiers”, Phys. Rev. A 101, 032308 (2020).

Examples

>>> from pyqit.ansatzes import SELAnsatz
>>> from pyqit.models import VQCClassifier
>>> model = VQCClassifier(n_qubits=4, n_layers=3, ansatz=SELAnsatz)
build_circuit(weights)[source]#

Construct and apply the strongly entangling layers to the quantum circuit.

Parameters:

weights (dict) – A dictionary containing the parameter tensors. Must include the key “weights” with a tensor of shape (n_layers, n_qubits, 3).

get_circuit_func()#

Returns the bound method to be passed to a QNode.

classmethod get_test_params()[source]#

Retrieve a set of default parameters for testing the ansatz.

Returns:

A list containing a dictionary of valid initialization parameters for the class.

Return type:

list of dict

get_weight_shapes() → dict[source]#

Get the shapes of the trainable weights required by the ansatz.

Returns:

A dictionary mapping the weight parameter name (“weights”) to its expected shape tuple (n_layers, n_qubits, 3).

Return type:

dict