PowerSeriesGradientPerturbation#
- class PowerSeriesGradientPerturbation(func, grad, func_args=None, grad_args=None, n_red=1, step_size=0.5, step_size_modifier=1.0, n_restart=-1, disable_gradient_scaling=False, iterative_scaling=False, bypass_objective_decrease=False)[source]#
Bases:
GradientPerturbationObjective function perturbation using gradient descent with step size reduction according to a power series. Has the option to restart the power series after a certain number of steps.
- Parameters:
func (
Callable) – The function to be reduced.grad (
Callable) – The gradient of the function to be reduced.func_args (
Optional[List]) – Additional arguments to be passed to the function, by default [].grad_args (
Optional[List]) – Additional arguments to be passed to the gradient function, by default [].n_red (
int) – The number of reductions, by default 1.step_size (
float) – The step size for the gradient descent, by default 0.5.step_size_modifier (
float) – Scaling factor for the step size power series, by default 1.0.n_restart (
int) – The number of steps after which to restart the power series, by default -1 (no restart).disable_gradient_scaling (
bool) – If true, skip the normalization of the gradient, by default False.iterative_scaling (
bool) – If true, the power series is scaled by the iteration k without checking whether this actually decreases the objective, by default False.bypass_objective_decrease (
bool) – If true, the check whether the objective function value actually decreases is bypassed, by default False.
Methods
Perform n_red perturbation steps on the input array.
post_step(x, *args, **kwargs)If required perform any form of step after each perturbation in each iteration.
pre_step(x, *args, **kwargs)Resets the power series after n steps.
reset()Reset the perturbation to its initial state.
- perturbation_step(x)#
Perform n_red perturbation steps on the input array.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – The input array to be perturbed.- Return type:
ndarray- Returns:
The perturbed array after applying the reduction steps.
- post_step(x, *args, **kwargs)#
If required perform any form of step after each perturbation in each iteration.
This method is intended to be overridden by subclasses to implement specific post-step logic. By default, it does nothing.
- Parameters:
x (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Current iterate.- Return type:
None