VQC¶
- class VQC(num_qubits=None, feature_map=None, ansatz=None, loss='cross_entropy', optimizer=None, warm_start=False, quantum_instance=None, initial_point=None, callback=None)[ソース]¶
ベースクラス:
NeuralNetworkClassifier
Variational quantum classifier.
The variational quantum classifier is a variational algorithm where the measured expectation value is interpreted as the output of a classifier.
Only supports one-hot encoded labels; e.g., data like
[1, 0, 0]
,[0, 1, 0]
,[0, 0, 1]
.Multi-label classification is not supported; e.g., data like
[1, 1, 0]
,[0, 1, 1]
,[1, 0, 1]
,[1, 1, 1]
.- パラメータ
num_qubits (
Optional
[int
]) – The number of qubits for the underlying CircuitQNN. If None, derive from feature_map or ansatz. If neither of those is given, raise exception.feature_map (
Optional
[QuantumCircuit
]) – The feature map for underlying CircuitQNN. If None, use ZZFeatureMap.ansatz (
Optional
[QuantumCircuit
]) – The ansatz for the underlying CircuitQNN. If None, use RealAmplitudes.loss (
Union
[str
,Loss
]) – A target loss function to be used in training. Default is cross entropy.optimizer (
Optional
[Optimizer
]) – An instance of an optimizer to be used in training. When None defaults to SLSQP.warm_start (
bool
) – Use weights from previous fit to start next fit.quantum_instance (
Optional
[QuantumInstance
]) – The quantum instance to execute circuits on.initial_point (
Optional
[ndarray
]) – Initial point for the optimizer to start from.callback (
Optional
[Callable
[[ndarray
,float
],None
]]) – a reference to a user’s callback function that has two parameters and returnsNone
. The callback can access intermediate data during training. On each iteration an optimizer invokes the callback and passes current weights as an array and a computed value as a float of the objective function being optimized. This allows to track how well optimization / training process is going on.
- 例外
QiskitMachineLearningError – Needs at least one out of num_qubits, feature_map or ansatz to be given.
Attributes
Returns the used ansatz.
Returns the underlying quantum circuit.
Returns the used feature map.
Returns the number of qubits used by ansatz and feature map.
Methods
fit
(X, y)Fit the model to data matrix X and targets y.