NeuralNetwork¶
- class NeuralNetwork(num_inputs, num_weights, sparse, output_shape, input_gradients=False)[source]¶
Bases:
abc.ABC
Abstract Neural Network class providing forward and backward pass and handling batched inputs. This is to be implemented by other (quantum) neural networks.
- Tham số
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 (
Union
[int
,Tuple
[int
, ...]]) -- The shape of the output.input_gradients (
bool
) -- Determines whether to compute gradients with respect to input data.
- Đưa ra
QiskitMachineLearningError -- Invalid parameter values.
Attributes
Returns whether gradients with respect to input data are computed by this neural network in the
backward
method or not.Returns the number of input features.
Returns the number of trainable weights.
Returns the output shape.
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.