Korean
언어
English
Bengali
French
Hindi
Japanese
Korean
Russian
Spanish
Tamil
Turkish



SamplingNeuralNetwork

class SamplingNeuralNetwork(num_inputs, num_weights, sparse, sampling, output_shape, input_gradients=False)[소스]

기반 클래스: 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.

매개변수:
  • 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 (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 is False by default, and must be explicitly set to True for a proper gradient computation when using TorchConnector.

예외 발생:

QiskitMachineLearningError – Invalid parameter values.

Attributes

input_gradients

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

num_inputs

Returns the number of input features.

num_weights

Returns the number of trainable weights.

output_shape

Returns the output shape.

sampling

Returns: True if the network returns a batch of samples and False if a sparse vector (dictionary) of probabilities in its forward pass.

sparse

Returns whether the output is sparse or not.

Methods

backward(input_data, weights)

Backward pass of the network.

forward(input_data, weights)

Forward pass of the network.

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.