QrTrainableFidelityQuantumKernel module
- class QrTrainableFidelityQuantumKernel(*, feature_map, fidelity, training_parameters, enforce_psd, evaluate_duplicates)
An implementation of the quantum kernel that is based on the
BaseStateFidelityalgorithm and provides ability to train it.This class is a derivative of the Qiskit Machine Learning Package
TrainableFidelityQuantumKernel. Please refer to the class for more documentation.Finding good quantum kernels for a specific machine learning task is a big challenge in quantum machine learning. One way to choose the kernel is to add trainable parameters to the feature map, which can be used to fine-tune the kernel.
This kernel has trainable parameters \(\theta\) that can be bound using training algorithms. The kernel entries are given as
\[K_{\theta}(x,y) = |\langle \phi_{\theta}(x) | \phi_{\theta}(y) \rangle|^2\]
- __init__(self, *, feature_map, fidelity, training_parameters, enforce_psd, evaluate_duplicates)
- Args:
- feature_map: Parameterized circuit to be used as the feature map. If
Noneis given,ZZFeatureMapis used with two qubits. If there’sa mismatch in the number of qubits of the feature map and the number of featuresin the dataset, then the kernel will try to adjust the feature map to reflect thenumber of features.fidelity: An instance of theBaseStateFidelityprimitive to be usedto compute fidelity between states. Default isComputeUncomputewhich is created ontop of the reference sampler defined bySampler.training_parameters: Iterable containingParameterobjectswhich correspond to quantum gates on the feature map circuit which may be tuned.If users intend to tune feature map parameters to find optimal values, this fieldshould be set.enforce_psd: Project to the closest positive semidefinite matrix ifx = y.DefaultTrue.evaluate_duplicates: Defines a strategy how kernel matrix elements are evaluated ifduplicate samples are found. Possible values are:-allmeans that all kernel matrix elements are evaluated, even the diagonalones when training. This may introduce additional noise in the matrix.-off_diagonalwhen training the matrix diagonal is set to 1, the restelements are fully evaluated, e.g., for two identical samples in thedataset. When inferring, all elements are evaluated. This is the defaultvalue.-nonewhen training the diagonal is set to 1 and if two identical samplesare found in the dataset the corresponding matrix element is set to 1.When inferring, matrix elements for identical samples are set to 1.