secml.optim.optimizers.line_search¶
CLineSearch¶
-
class
secml.optim.optimizers.line_search.c_line_search.
CLineSearch
(fun, constr=None, bounds=None, eta=0.0001, max_iter=20)[source]¶ Bases:
secml.core.c_creator.CCreator
Abstract class that implements line-search optimization algorithms.
Line-search algorithms optimize the objective function along a given direction in the feasible domain, potentially subject to constraints. The search is normally stopped when the objective improves at a satisfying level, to keep the search fast.
- Attributes
class_type
Defines class type.
logger
Logger for current object.
verbose
Verbosity level of logger output.
Methods
copy
(self)Returns a shallow copy of current class.
create
([class_item])This method creates an instance of a class with given type.
deepcopy
(self)Returns a deep copy of current class.
get_class_from_type
(class_type)Return the class associated with input type.
get_params
(self)Returns the dictionary of class parameters.
get_subclasses
()Get all the subclasses of the calling class.
list_class_types
()This method lists all types of available subclasses of calling one.
load
(path)Loads class from pickle object.
minimize
(self, x, d, \*\*kwargs)Line search.
save
(self, path)Save class object using pickle.
set
(self, param_name, param_value[, copy])Set a parameter that has a specific name to a specific value.
set_params
(self, params_dict[, copy])Set all parameters passed as a dictionary {key: value}.
timed
([msg])Timer decorator.
CLineSearchBisect¶
-
class
secml.optim.optimizers.line_search.c_line_search_bisect.
CLineSearchBisect
(fun, constr=None, bounds=None, eta=0.0001, eta_min=0.1, eta_max=None, max_iter=20)[source]¶ Bases:
secml.optim.optimizers.line_search.c_line_search.CLineSearch
Binary line search.
- Attributes
class_type
‘bisect’Defines class type.
Methods
copy
(self)Returns a shallow copy of current class.
create
([class_item])This method creates an instance of a class with given type.
deepcopy
(self)Returns a deep copy of current class.
get_class_from_type
(class_type)Return the class associated with input type.
get_params
(self)Returns the dictionary of class parameters.
get_subclasses
()Get all the subclasses of the calling class.
list_class_types
()This method lists all types of available subclasses of calling one.
load
(path)Loads class from pickle object.
minimize
(self, x, d[, fx, tol])Bisect line search (on discrete grid).
save
(self, path)Save class object using pickle.
set
(self, param_name, param_value[, copy])Set a parameter that has a specific name to a specific value.
set_params
(self, params_dict[, copy])Set all parameters passed as a dictionary {key: value}.
timed
([msg])Timer decorator.
-
property
eta_max
¶
-
property
eta_min
¶
-
minimize
(self, x, d, fx=None, tol=0.0001, **kwargs)[source]¶ Bisect line search (on discrete grid).
The function fun( x + a*eta*d ) with a = {0, 1, 2, … } is minimized along the descent direction d.
If fun(x) >= 0 -> step_min = step else step_max = step
If eta_max is not None, it runs a bisect line search in [x + eta_min*d, x + eta_max*d]; otherwise, it runs an exponential line search in `[x + eta*d, …, x + eta_min*d, …]
- Parameters
- xCArray
The input point.
- dCArray
The descent direction along which fun(x) is minimized.
- fxint or float or None, optional
The current value of fun(x) (if available).
- tolfloat, optional
Tolerance for convergence to the local minimum.
- kwargsdict
Additional parameters required to evaluate fun(x, **kwargs).
- Returns
- x’CArray
Point x’ = x + eta * d that approximately solves min f(x + eta*d).
- fx’: int or float or None, optional
The value f(x’).
-
property
n_iter
¶