NeuralNetworkRegressor¶
- class NeuralNetworkRegressor(neural_network, loss='squared_error', optimizer=None, warm_start=False, initial_point=None, callback=None)[исходный код]¶
Базовые классы:
TrainableModel
,RegressorMixin
Quantum neural network regressor. Implements Scikit-Learn compatible methods for regression and extends
RegressorMixin
. See Scikit-Learn for more details.- Параметры
neural_network (
NeuralNetwork
) – An instance of an quantum neural network. If the neural network has a one-dimensional output, i.e., neural_network.output_shape=(1,), then it is expected to return values in [-1, +1] and it can only be used for binary classification. If the output is multi-dimensional, it is assumed that the result is a probability distribution, i.e., that the entries are non-negative and sum up to one. Then there are two options, either one-hot encoding or not. In case of one-hot encoding, each probability vector resulting a neural network is considered as one sample and the loss function is applied to the whole vector. Otherwise, each entry of the probability vector is considered as an individual sample and the loss function is applied to the index and weighted with the corresponding probability.loss (
Union
[str
,Loss
]) – A target loss function to be used in training. Default is squared_error, i.e. L2 loss. Can be given either as a string for „absolute_error“ (i.e. L1 Loss), „squared_error“, „cross_entropy“, „cross_entropy_sigmoid“, or as a loss function implementing the Loss interface.optimizer (
Optional
[Optimizer
]) – An instance of an optimizer to be used in training. When None defaults to SLSQP.warm_start (
bool
) – Use weights from previous fit to start next fit.initial_point (
Optional
[ndarray
]) – Initial point for the optimizer to start from.callback (
Optional
[Callable
[[ndarray
,float
],None
]]) – a reference to a user’s callback function that has two parameters and returnsNone
. The callback can access intermediate data during training. On each iteration an optimizer invokes the callback and passes current weights as an array and a computed value as a float of the objective function being optimized. This allows to track how well optimization / training process is going on.
- Исключение
QiskitMachineLearningError – unknown loss, invalid neural network
Attributes
Methods
fit
(X, y)Fit the model to data matrix X and target(s) y.
predict
(X)Predict using the network specified to the model.
score
(X, y[, sample_weight])Returns a score of this model given samples and true values for the samples.