SamplingNeuralNetwork¶
- class SamplingNeuralNetwork(num_inputs, num_weights, sparse, sampling, output_shape, input_gradients=False)[source]¶
Bases :
qiskit_machine_learning.neural_networks.neural_network.NeuralNetwork
A Sampling Neural Network abstract class for all (quantum) neural networks within Qiskit’s machine learning module that generate samples instead of (expected) values.
- Paramètres
num_inputs (
int
) – The number of input features.num_weights (
int
) – The number of 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.output_shape (
Union
[int
,Tuple
[int
, …]]) – The shape of the output.input_gradients (
bool
) – Determines whether to compute gradients with respect to input data. Note that this parameter isFalse
by default, and must be explicitly set toTrue
for a proper gradient computation when usingTorchConnector
.
- Lève
QiskitMachineLearningError – Invalid parameter values.
Attributes
Returns:
True
if the network returns a batch of samples andFalse
if a sparse vector (dictionary) of probabilities in its forward pass.Methods
probabilities
(input_data, weights)Histogram (as dict) of the samples from the network.
probability_gradients
(input_data, weights)Probability gradients of histogram resulting from the network.
sample
(input_data, weights)Samples from the network.