squlearn.encoding_circuit
.HubregtsenEncodingCircuit
- class squlearn.encoding_circuit.HubregtsenEncodingCircuit(num_qubits: int, num_features: int, num_layers: int = 1, closed: bool = True, final_encoding=False)
Creates the data reuploading encoding circuit as presented in reference [1].
Example for 4 qubits, a 2 dimensional feature vector, 2 layers:
(
Source code
,png
,hires.png
,pdf
)The encoding can be optionally repeated at the end to make the previous rotations not redundant in a fidelity kernel setting. The circuit is closed by default, i.e. the last qubit is entangled with the first one.
- Parameters:
num_qubits (int) – Number of qubits of the encoding circuit
num_features (int) – Dimension of the feature vector
num_layers (int) – Number of layers (default:1)
closed (bool) – If true, the last and the first qubit are entangled; not necessarily hardware efficient! (default: true)
final_encoding (bool) – If True, the encoding is repeated at the end (default: False)
References
[1]: T. Hubregtsen et al., “Training Quantum Embedding Kernels on Near-Term Quantum Computers”, arXiv:2105.02276v1 (2021).
- 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 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 Hubregtsen 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:
Returns the Hubregtsen circuit in qiskit QuantumCircuit format
- get_params(deep: bool = True) dict
Returns hyper-parameters and their values of the Hubregtsen 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
.