Turkish
Diller
English
Bengali
French
Hindi
Italian
Japanese
Korean
Malayalam
Russian
Spanish
Tamil
Turkish
Vietnamese
Shortcuts



CircuitQNN

class CircuitQNN(circuit, input_params=None, weight_params=None, sparse=False, sampling=False, interpret=None, output_shape=None, gradient=None, quantum_instance=None, input_gradients=False)[kaynak]

Bases: qiskit_machine_learning.neural_networks.sampling_neural_network.SamplingNeuralNetwork

A Sampling Neural Network based on a given quantum circuit.

Parametreler
  • circuit (QuantumCircuit) – The parametrized quantum circuit that generates the samples of this network.

  • input_params (Optional[List[Parameter]]) – The parameters of the circuit corresponding to the input.

  • weight_params (Optional[List[Parameter]]) – The parameters of the circuit corresponding to the trainable weights.

  • sparse (bool) – Returns whether the output is sparse or not.

  • sampling (bool) – Determines whether the network returns a batch of samples or (possibly sparse) array of probabilities in its forward pass. In case of probabilities, the backward pass returns the probability gradients, while it returns (None, None) in the case of samples. Note that sampling==True will always result in a dense return array independent of the other settings.

  • interpret (Optional[Callable[[int], Union[int, Tuple[int, …]]]]) – A callable that maps the measured integer to another unsigned integer or tuple of unsigned integers. These are used as new indices for the (potentially sparse) output array. If this is used, and sampling==False, the output shape of the output needs to be given as a separate argument. If no interpret function is passed, then an identity function will be used by this neural network.

  • output_shape (Union[int, Tuple[int, …], None]) – The output shape of the custom interpretation, only used in the case where an interpret function is provided and sampling==False. Note that in the remaining cases, the output shape is automatically inferred by: 2^num_qubits if sampling==False and interpret==None, (num_samples,1) if sampling==True and interpret==None, and (num_samples, interpret_shape) if sampling==True and an interpret function is provided.

  • gradient (Optional[Gradient]) – The gradient converter to be used for the probability gradients.

  • quantum_instance (Union[QuantumInstance, BaseBackend, Backend, None]) – The quantum instance to evaluate the circuits. Note that if sampling==True, a statevector simulator is not a valid backend for the quantum instance.

  • input_gradients (bool) – Determines whether to compute gradients with respect to input data. Note that this parameter is False by default, and must be explicitly set to True for a proper gradient computation when using TorchConnector.

Harekete geçirir

QiskitMachineLearningError – if interpret is passed without output_shape.

Attributes

circuit

Returns the underlying quantum circuit.

input_gradients

Returns whether gradients with respect to input data are computed by this neural network in the backward method or not.

input_params

Returns the list of input parameters.

interpret

Returns interpret function to be used by the neural network.

quantum_instance

Returns the quantum instance to evaluate the circuit.

weight_params

Returns the list of trainable weights parameters.

Methods

set_interpret(interpret[, output_shape])

Change 'interpret' and corresponding 'output_shape'.