My Project
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cpu_mlp::FullBatchMinimizer< V, M > Class Template Referenceabstract

Base class for Full Batch Minimizers. More...

#include <full_batch_minimizer.hpp>

Inheritance diagram for cpu_mlp::FullBatchMinimizer< V, M >:
Inheritance graph
[legend]
Collaboration diagram for cpu_mlp::FullBatchMinimizer< V, M >:
Collaboration graph
[legend]

Public Member Functions

virtual ~FullBatchMinimizer ()=default
 
virtual V solve (V x, VecFun< V, double > &f, GradFun< V > &Gradient)=0
 Performs optimization. More...
 
virtual void setInitialHessian (const M &)
 Sets the initial Hessian approximation (if applicable). More...
 
virtual void setHessian (const HessFun< V, M > &)
 Sets the Hessian function (for Second Order methods). More...
 
template<auto LossFn, typename DataType >
solve_with_enzyme (V x, DataType *data)
 Helper to solve directly using an Enzyme-compatible raw function. More...
 
void setMaxIterations (int max_iters)
 Sets the maximum number of iterations. More...
 
void setMaxLineIters (int max_line)
 Sets the maximum number of iterations for the line search. More...
 
void setArmijoMaxIter (int max_armijo)
 Sets the maximum iterations for Armijo condition check (alias for setMaxLineIters). More...
 
void setTolerance (double tol)
 Sets the tolerance for convergence. More...
 
unsigned int iterations () const
 Returns the number of iterations performed. More...
 
double tolerance () const
 Returns the tolerance used. More...
 
void setRecorder (::IterationRecorder< CpuBackend > *recorder)
 Attach a recorder for loss/grad history. More...
 

Protected Member Functions

double line_search (V x, V p, VecFun< V, double > &f, GradFun< V > &Gradient)
 Backtracking Line Search satisfying Wolfe Conditions. More...
 

Protected Attributes

unsigned int _max_iters = 1000
 
unsigned int _iters = 0
 
double _tol = 1e-10
 
::IterationRecorder< CpuBackend > * recorder_ = nullptr
 Optional recorder for diagnostics. More...
 
double c1 = 1e-4
 
double c2 = 0.9
 
double rho = 0.5
 
double max_line_iters = 50
 

Detailed Description

template<typename V, typename M>
class cpu_mlp::FullBatchMinimizer< V, M >

Base class for Full Batch Minimizers.

Implements common functionalities such as Line Search for deterministic optimization.

Constructor & Destructor Documentation

◆ ~FullBatchMinimizer()

template<typename V , typename M >
virtual cpu_mlp::FullBatchMinimizer< V, M >::~FullBatchMinimizer ( )
virtualdefault

Member Function Documentation

◆ iterations()

template<typename V , typename M >
unsigned int cpu_mlp::FullBatchMinimizer< V, M >::iterations ( ) const
inline

Returns the number of iterations performed.

Returns
Iteration count.

◆ line_search()

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::line_search ( x,
p,
VecFun< V, double > &  f,
GradFun< V > &  Gradient 
)
inlineprotected

Backtracking Line Search satisfying Wolfe Conditions.

Parameters
xCurrent position.
pSearch direction.
fObjective function.
GradientGradient function.
Returns
Step length alpha.
Here is the caller graph for this function:

◆ setArmijoMaxIter()

template<typename V , typename M >
void cpu_mlp::FullBatchMinimizer< V, M >::setArmijoMaxIter ( int  max_armijo)
inline

Sets the maximum iterations for Armijo condition check (alias for setMaxLineIters).

Parameters
max_armijoMaximum iterations.

◆ setHessian()

template<typename V , typename M >
virtual void cpu_mlp::FullBatchMinimizer< V, M >::setHessian ( const HessFun< V, M > &  )
inlinevirtual

Sets the Hessian function (for Second Order methods).

Parameters
hessFunFunction to compute the Hessian.

Reimplemented in cpu_mlp::Newton< V, M >.

◆ setInitialHessian()

template<typename V , typename M >
virtual void cpu_mlp::FullBatchMinimizer< V, M >::setInitialHessian ( const M &  )
inlinevirtual

Sets the initial Hessian approximation (if applicable).

Parameters
hessInitial Hessian matrix.

Reimplemented in cpu_mlp::BFGS< V, M, Solver >.

◆ setMaxIterations()

template<typename V , typename M >
void cpu_mlp::FullBatchMinimizer< V, M >::setMaxIterations ( int  max_iters)
inline

Sets the maximum number of iterations.

Parameters
max_itersLimit on iterations.

◆ setMaxLineIters()

template<typename V , typename M >
void cpu_mlp::FullBatchMinimizer< V, M >::setMaxLineIters ( int  max_line)
inline

Sets the maximum number of iterations for the line search.

Parameters
max_lineMaximum line search iterations.

◆ setRecorder()

template<typename V , typename M >
void cpu_mlp::FullBatchMinimizer< V, M >::setRecorder ( ::IterationRecorder< CpuBackend > *  recorder)
inline

Attach a recorder for loss/grad history.

Parameters
recorderRecorder instance (may be null).

◆ setTolerance()

template<typename V , typename M >
void cpu_mlp::FullBatchMinimizer< V, M >::setTolerance ( double  tol)
inline

Sets the tolerance for convergence.

Parameters
tolTolerance value (gradient norm).

◆ solve()

template<typename V , typename M >
virtual V cpu_mlp::FullBatchMinimizer< V, M >::solve ( x,
VecFun< V, double > &  f,
GradFun< V > &  Gradient 
)
pure virtual

Performs optimization.

Parameters
xInitial guess.
fObjective function.
GradientGradient function.
Returns
Optimized parameter vector.

Implemented in cpu_mlp::Newton< V, M >, cpu_mlp::LBFGS< V, M >, cpu_mlp::GradientDescent< V, M >, and cpu_mlp::BFGS< V, M, Solver >.

Here is the caller graph for this function:

◆ solve_with_enzyme()

template<typename V , typename M >
template<auto LossFn, typename DataType >
V cpu_mlp::FullBatchMinimizer< V, M >::solve_with_enzyme ( x,
DataType *  data 
)
inline

Helper to solve directly using an Enzyme-compatible raw function.

Template Parameters
LossFnThe raw C++ function pointer for the loss .
DataTypeThe type of the data structure passed to the loss.
Parameters
xInitial parameter vector.
dataPointer to the data structure.
Returns
Optimized parameter vector.
Here is the call graph for this function:

◆ tolerance()

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::tolerance ( ) const
inline

Returns the tolerance used.

Returns
Tolerance value.

Member Data Documentation

◆ _iters

template<typename V , typename M >
unsigned int cpu_mlp::FullBatchMinimizer< V, M >::_iters = 0
protected

◆ _max_iters

template<typename V , typename M >
unsigned int cpu_mlp::FullBatchMinimizer< V, M >::_max_iters = 1000
protected

◆ _tol

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::_tol = 1e-10
protected

◆ c1

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::c1 = 1e-4
protected

◆ c2

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::c2 = 0.9
protected

◆ max_line_iters

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::max_line_iters = 50
protected

◆ recorder_

template<typename V , typename M >
::IterationRecorder<CpuBackend>* cpu_mlp::FullBatchMinimizer< V, M >::recorder_ = nullptr
protected

Optional recorder for diagnostics.

◆ rho

template<typename V , typename M >
double cpu_mlp::FullBatchMinimizer< V, M >::rho = 0.5
protected

The documentation for this class was generated from the following file: