squlearn.encoding_circuit
.PrunedEncodingCircuit
- class squlearn.encoding_circuit.PrunedEncodingCircuit(encoding_circuit: EncodingCircuitBase, pruned_parameters: list)
Class for pruning redundant parameter of encoding circuits.
This class is designed to accept a encoding circuit and selectively prune parameters based on a provided list of indices. The pruned encoding circuit can be used as a usual encoding circuit.
Example: Pruned Hubregtsen Encoding Circuit
from squlearn.encoding_circuit import HubregtsenEncodingCircuit,PrunedEncodingCircuit fm = HubregtsenEncodingCircuit(4,2,2) PrunedEncodingCircuit(fm,[4,7,11,15]).draw("mpl")
- Parameters:
encoding_circuit (EncodingCircuitBase) – EncodingCircuit from which the parameters are removed
pruned_parameters (list) – list with indices of the redundant parameters
- draw(output: str = None, feature_label: str = 'x', parameter_label: str = 'p', decompose: bool = False, **kwargs) None
Draws the encoding circuit circuit using the QuantumCircuit.draw() function.
- Parameters:
feature_label (str) – Label for the feature vector (default:”x”).
parameter_label (str) – Label for the parameter vector (default:”p”).
decompose (bool) – If True, the circuit is decomposed before printing (default: False).
kwargs – Additional arguments from Qiskit’s QuantumCircuit.draw() function.
- Returns:
Returns the circuit in qiskit QuantumCircuit.draw() format
- generate_initial_parameters(seed: int | None = None) ndarray
Generates random parameters for the pruned encoding circuit.
- Parameters:
seed (Union[int,None]) – Seed for the random number generator (default: None)
- Returns:
The randomly generated parameters
- get_circuit(features: ParameterVector | ndarray, parameters: ParameterVector | ndarray) QuantumCircuit
Generates and returns the circuit of the pruned encoding circuit.
- Parameters:
features (Union[ParameterVector,np.ndarray]) – Input vector of the features from which the gate inputs are obtained
param_vec (Union[ParameterVector,np.ndarray]) – Input vector of the parameters from which the gate inputs are obtained
- Returns:
The circuit in Qiskit’s QuantumCircuit format of the pruned encoding circuit.
- get_params(deep: bool = True) dict
Returns hyper-parameters and their values of the encoding circuit.
- Parameters:
deep (bool) – If True, also the parameters for contained objects are returned (default=True).
- Returns:
Dictionary with hyper-parameters and values.
- set_params(**params) EncodingCircuitBase
Sets value of the encoding circuit hyper-parameters.
- Parameters:
params – Hyper-parameters and their values, e.g.
num_qubits=2
.