squlearn.qnn.lowlevel_qnn
.LowLevelQNN
- class squlearn.qnn.lowlevel_qnn.LowLevelQNN(parameterized_quantum_circuit: EncodingCircuitBase, observable: ObservableBase | list, executor: Executor, *args, **kwargs)
Low-level QNN factory, which creates the specific low-level QNN based on the quantum framework.
- Parameters:
pqc (EncodingCircuitBase) – The parameterized quantum circuit.
observable (Union[ObservableBase, list]) – The observable(s) to measure.
executor (Executor) – The executor for the quantum circuit.
*args – Additional arguments that are passed to the specific QNN.
**kwargs – Additional keyword arguments that are passed to the specific QNN.
- Returns
LowLevelQNNBase: The specific low-level QNN based on the quantum framework.
- abstract evaluate(x: float | ndarray, param: float | ndarray, param_obs: float | ndarray, *values: str | ParameterVector | ParameterVectorElement | tuple) dict
General function for evaluating the output of derivatives of the QNN.
Evaluation works for given combination of input features x and parameters param and param_op. The function includes caching of results
If x, param, and/or param_op are given as a nested list (for example multiple sets of parameters), the values are returned in a nested list.
- Parameters:
x (np.ndarray) – Values of the input feature data.
param (np.ndarray) – Parameter values of the PQC parameters
param_op (np.ndarray) – Parameter values of the operator parameters
values – Derivatives (or values) of the QNN that are evaluated. Higher order derivatives are given as tuples of parameters or vectors.
- Results:
Returns a dictionary with the computed values. The keys of the dictionary are given by the entries in the values tuple
- abstract get_params(deep: bool = True) dict
Get the parameters of the QNN.
- gradient(x: float | ndarray, param: float | ndarray, param_obs: float | ndarray)
Return the gradient wrt. trainable parameters of the QNN.
- Parameters:
x (Union[float, np.ndarray]) – Input data.
param (Union[float, np.ndarray]) – Parameters of the PQC.
param_obs (Union[float, np.ndarray]) – Parameters of the observable.
- Returns:
Gradient of the QNN.
- Return type:
np.ndarray
- abstract set_params(**params) None
Set the parameters of the QNN.