BinaryObjectiveFunction#

class BinaryObjectiveFunction(X, y, neural_network, loss)[source]#

Bases: ObjectiveFunction

An objective function for binary representation of the output. For instance, classes of -1 and +1.

Parameters:
  • X (ndarray) -- The input data.

  • y (ndarray) -- The target values.

  • neural_network (NeuralNetwork) -- An instance of an quantum neural network to be used by this objective function.

  • loss (Loss) -- A target loss function to be used in training.

Methods

gradient(weights)[source]#

Computes gradients of this objective function given weights.

Parameters:

weights (ndarray) -- an array of weights to be used in the objective function.

Returns:

Gradients of the function.

Return type:

ndarray

objective(weights)[source]#

Computes the value of this objective function given weights.

Parameters:

weights (ndarray) -- an array of weights to be used in the objective function.

Returns:

Value of the function.

Return type:

float