squlearn.qnn.lowlevel_qnn_base
.LowLevelQNNBase
- class squlearn.qnn.lowlevel_qnn_base.LowLevelQNNBase(parameterized_quantum_circuit: EncodingCircuitBase, observable: ObservableBase | list, executor: Executor)
Base class for low-level QNNs.
- Parameters:
pqc (EncodingCircuitBase) – The parameterized quantum circuit.
observable (Union[ObservableBase, list]) – The observable(s) to measure.
executor (Executor) – The executor for the quantum circuit.
- 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.