NeuralNetwork#
- class NeuralNetwork(num_inputs, num_weights, sparse, output_shape, input_gradients=False)[स्रोत]#
आधार:
ABC
Abstract Neural Network class providing forward and backward pass and handling batched inputs. This is to be implemented by other (quantum) neural networks.
- मापदण्ड:
num_inputs (int) -- The number of input features.
num_weights (int) -- The number of trainable weights.
sparse (bool) -- Determines whether the output is a sparse array or not.
output_shape (int | tuple[int, ...]) -- The shape of the output.
input_gradients (bool) -- Determines whether to compute gradients with respect to input data.
- उभारता है :
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. By default such gradients are not computed.
- num_inputs#
Returns the number of input features.
- num_weights#
Returns the number of trainable weights.
- output_shape#
Returns the output shape.
- sparse#
Returns whether the output is sparse or not.
Methods
- backward(input_data, weights)[स्रोत]#
Backward pass of the network.
- मापदण्ड:
input_data (float | list[float] | ndarray | None) -- input data of the shape (num_inputs). In case of a single scalar input it is directly cast to and interpreted like a one-element array.
weights (float | list[float] | ndarray | None) -- trainable weights of the shape (num_weights). In case of a single scalar weight
array. (it is directly cast to and interpreted like a one-element) --
- प्रदत्त :
The result of the neural network of the backward pass, i.e., a tuple with the gradients for input and weights of shape (output_shape, num_input) and (output_shape, num_weights), respectively.
- प्रदत्त प्रकार :
tuple[numpy.ndarray | qiskit_machine_learning.neural_networks.neural_network.SparseArray | None, numpy.ndarray | qiskit_machine_learning.neural_networks.neural_network.SparseArray | None]
- forward(input_data, weights)[स्रोत]#
Forward pass of the network.
- मापदण्ड:
input_data (float | list[float] | ndarray | None) -- input data of the shape (num_inputs). In case of a single scalar input it is directly cast to and interpreted like a one-element array.
weights (float | list[float] | ndarray | None) -- trainable weights of the shape (num_weights). In case of a single scalar weight it is directly cast to and interpreted like a one-element array.
- प्रदत्त :
The result of the neural network of the shape (output_shape).
- प्रदत्त प्रकार :
ndarray | SparseArray