quara.loss_function.simple_quadratic_loss_function module

class SimpleQuadraticLossFunction(var_ref)[source]

Bases: quara.loss_function.loss_function.LossFunction

Constructor

this class has following properties.

  • on_value = True

  • on_gradient = True

  • on_hessian = True

Parameters

var_ref (np.ndarray) – variables

gradient(var, validate=False)[source]

returns the gradient of the loss function.

the value of the loss function is \(2(\text{var} - \text{var_ref})\).

Parameters
  • var (np.ndarray) – np.ndarray of variables.

  • validate (bool) –

Returns

the gradient of the loss function. dtype=np.float64

Return type

np.ndarray

Raises

ValueError – the shape of variable is not (num_var,).

hessian(var, validate=False)[source]

returns the Hessian of the loss function.

the value of the loss function is 2I, where I is the identity matrix of size num_var.

Parameters
  • var (np.ndarray) – np.ndarray of variables.

  • validate (bool) –

Returns

the Hessian of the loss function. dtype=np.float64

Return type

np.ndarray

Raises

ValueError – the shape of variable is not (num_var,).

value(var, validate=False)[source]

returns the value of the loss function.

the value of the loss function is \(|| \text{var} - \text{var_ref} ||^2_2\).

Parameters
  • var (np.ndarray) – np.ndarray of variables.

  • validate (bool) –

Returns

the value of the loss function.

Return type

np.float64

Raises

ValueError – the shape of variable is not (num_var,).

class SimpleQuadraticLossFunctionOption[source]

Bases: quara.loss_function.loss_function.LossFunctionOption

Constructor

Parameters
  • mode_weight (str, optional) – mode weight, by default None

  • weights (List, optional) – list of weight, by default None

  • weight_name (str, optional) – weight name for reporting, by default None