TrainableFidelityStatevectorKernel#

class TrainableFidelityStatevectorKernel(*, feature_map=None, statevector_type=<class 'qiskit.quantum_info.states.statevector.Statevector'>, training_parameters=None, cache_size=None, auto_clear_cache=True, shots=None, enforce_psd=True)[स्रोत]#

आधार: TrainableKernel, FidelityStatevectorKernel

A trainable version of the FidelityStatevectorKernel.

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\]
मापदण्ड:
  • feature_map (QuantumCircuit | None) -- Parameterized circuit to be used as the feature map. If None is given, ZZFeatureMap is used with two qubits. If there's a mismatch in the number of qubits of the feature map and the number of features in the dataset, then the kernel will try to adjust the feature map to reflect the number of features.

  • statevector_type (Type[SV]) -- The type of Statevector that will be instantiated using the feature_map quantum circuit and used to compute the fidelity kernel. This type should inherit from (and defaults to) Statevector.

  • training_parameters (ParameterVector | Sequence[Parameter] | None) -- Iterable containing Parameter objects which 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 field should be set.

  • cache_size (int | None) -- Maximum size of the statevector cache. When None this is unbounded.

  • auto_clear_cache (bool) -- Determines whether the statevector cache is retained when evaluate() is called. The cache is automatically cleared by default.

  • shots (int | None) -- The number of shots. If None, the exact fidelity is used. Otherwise, the mean is taken of samples drawn from a binomial distribution with probability equal to the exact fidelity.

  • enforce_psd (bool) -- Project to the closest positive semidefinite matrix if x = y. Default True.

Attributes

enforce_psd#

Returns True if the kernel matrix is required to project to the closest positive semidefinite matrix.

feature_map#

Returns the feature map of this kernel.

num_features#

Returns the number of features in this kernel.

num_training_parameters#

Returns the number of training parameters.

parameter_values#

Returns numerical values assigned to the training parameters as a numpy array.

training_parameters#

Returns the vector of training parameters.

Methods

assign_training_parameters(parameter_values)#

Fix the training parameters to numerical values.

clear_cache()#

Clear the statevector cache.

evaluate(x_vec, y_vec=None)#

Construct kernel matrix for given data.

If y_vec is None, self inner product is calculated.

मापदण्ड:
  • x_vec (ndarray) -- 1D or 2D array of datapoints, NxD, where N is the number of datapoints, D is the feature dimension

  • y_vec (ndarray | None) -- 1D or 2D array of datapoints, MxD, where M is the number of datapoints, D is the feature dimension

प्रदत्त :

2D matrix, NxM

प्रदत्त प्रकार :

ndarray