go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
itk::PreconditionedGradientDescentOptimizer Class Reference

#include <itkPreconditionedGradientDescentOptimizer.h>

Detailed Description

Implement a gradient descent optimizer.

PreconditionedGradientDescentOptimizer implements a simple gradient descent optimizer. At each iteration the current position is updated according to

\[
         p_{n+1} = p_n
                 + \mbox{learningRate}
\, \frac{\partial f(p_n) }{\partial p_n}
  \]

The learning rate is a fixed scalar defined via SetLearningRate(). The optimizer steps through a user defined number of iterations; no convergence checking is done.

Additionally, user can scale each component of the $\partial f / \partial p$ but setting a scaling vector using method SetScale().

The difference of this class with the itk::GradientDescentOptimizer is that it's based on the ScaledSingleValuedNonLinearOptimizer

See also
ScaledSingleValuedNonLinearOptimizer

Definition at line 55 of file itkPreconditionedGradientDescentOptimizer.h.

+ Inheritance diagram for itk::PreconditionedGradientDescentOptimizer:

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::CostFunctionType CostFunctionType
 
typedef Superclass::DerivativeType DerivativeType
 
typedef Superclass::MeasureType MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef vnl_sparse_matrix< PreconditionValueTypePreconditionType
 
typedef DerivativeType::ValueType PreconditionValueType
 
typedef Superclass::ScaledCostFunctionPointer ScaledCostFunctionPointer
 
typedef Superclass::ScaledCostFunctionType ScaledCostFunctionType
 
typedef Superclass::ScalesType ScalesType
 
typedef PreconditionedGradientDescentOptimizer Self
 
enum  StopConditionType { MaximumNumberOfIterations , MetricError , MinimumStepSize }
 
typedef ScaledSingleValuedNonLinearOptimizer Superclass
 
- Public Types inherited from itk::ScaledSingleValuedNonLinearOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::CostFunctionType CostFunctionType
 
typedef Superclass::DerivativeType DerivativeType
 
typedef Superclass::MeasureType MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef ScaledCostFunctionType::Pointer ScaledCostFunctionPointer
 
typedef ScaledSingleValuedCostFunction ScaledCostFunctionType
 
typedef NonLinearOptimizer::ScalesType ScalesType
 
typedef ScaledSingleValuedNonLinearOptimizer Self
 
typedef SingleValuedNonLinearOptimizer Superclass
 

Public Member Functions

virtual void AdvanceOneStep (void)
 
const cholmod_common * GetCholmodCommon (void) const
 
const cholmod_factor * GetCholmodFactor (void) const
 
virtual const char * GetClassName () const
 
virtual double GetConditionNumber () const
 
virtual unsigned int GetCurrentIteration () const
 
virtual double GetDiagonalWeight () const
 
virtual const DerivativeTypeGetGradient ()
 
virtual double GetLargestEigenValue () const
 
virtual const doubleGetLearningRate ()
 
virtual double GetMinimumGradientElementMagnitude () const
 
virtual const unsigned long & GetNumberOfIterations ()
 
virtual const DerivativeTypeGetSearchDirection ()
 
virtual double GetSparsity () const
 
virtual const StopConditionTypeGetStopCondition ()
 
virtual const doubleGetValue ()
 
virtual void MetricErrorResponse (ExceptionObject &err)
 
virtual void ResumeOptimization (void)
 
virtual void SetDiagonalWeight (double _arg)
 
virtual void SetLearningRate (double _arg)
 
virtual void SetMinimumGradientElementMagnitude (double _arg)
 
virtual void SetNumberOfIterations (unsigned long _arg)
 
virtual void SetPreconditionMatrix (PreconditionType &precondition)
 
virtual void StartOptimization (void)
 
virtual void StopOptimization (void)
 
- Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
virtual const char * GetClassName () const
 
const ParametersTypeGetCurrentPosition (void) const override
 
virtual bool GetMaximize () const
 
virtual const ScaledCostFunctionTypeGetScaledCostFunction ()
 
virtual const ParametersTypeGetScaledCurrentPosition ()
 
bool GetUseScales (void) const
 
virtual void InitializeScales (void)
 
virtual void MaximizeOff ()
 
virtual void MaximizeOn ()
 
void SetCostFunction (CostFunctionType *costFunction) override
 
virtual void SetMaximize (bool _arg)
 
virtual void SetUseScales (bool arg)
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
static Pointer New ()
 

Protected Types

typedef int CInt
 

Protected Member Functions

virtual void CholmodSolve (const DerivativeType &gradient, DerivativeType &searchDirection, int solveType=CHOLMOD_A)
 
 PreconditionedGradientDescentOptimizer ()
 
void PrintSelf (std::ostream &os, Indent indent) const
 
virtual ~PreconditionedGradientDescentOptimizer ()
 
- Protected Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
virtual void GetScaledDerivative (const ParametersType &parameters, DerivativeType &derivative) const
 
virtual MeasureType GetScaledValue (const ParametersType &parameters) const
 
virtual void GetScaledValueAndDerivative (const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ScaledSingleValuedNonLinearOptimizer ()
 
void SetCurrentPosition (const ParametersType &param) override
 
virtual void SetScaledCurrentPosition (const ParametersType &parameters)
 
 ~ScaledSingleValuedNonLinearOptimizer () override
 

Protected Attributes

cholmod_common * m_CholmodCommon
 
cholmod_factor * m_CholmodFactor
 
cholmod_sparse * m_CholmodGradient
 
double m_ConditionNumber
 
DerivativeType m_Gradient
 
double m_LargestEigenValue
 
double m_LearningRate
 
DerivativeType m_SearchDirection
 
double m_Sparsity
 
StopConditionType m_StopCondition
 
- Protected Attributes inherited from itk::ScaledSingleValuedNonLinearOptimizer
ScaledCostFunctionPointer m_ScaledCostFunction
 
ParametersType m_ScaledCurrentPosition
 

Private Member Functions

void operator= (const Self &)
 
 PreconditionedGradientDescentOptimizer (const Self &)
 

Private Attributes

unsigned long m_CurrentIteration
 
double m_DiagonalWeight
 
double m_MinimumGradientElementMagnitude
 
unsigned long m_NumberOfIterations
 
bool m_Stop
 
double m_Value
 

Member Typedef Documentation

◆ CInt

Cholmod index type: define at central place

Definition at line 190 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ConstPointer

Definition at line 63 of file itkPreconditionedGradientDescentOptimizer.h.

◆ CostFunctionType

Definition at line 75 of file itkPreconditionedGradientDescentOptimizer.h.

◆ DerivativeType

Definition at line 74 of file itkPreconditionedGradientDescentOptimizer.h.

◆ MeasureType

Typedefs inherited from the superclass.

Definition at line 72 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ParametersType

Definition at line 73 of file itkPreconditionedGradientDescentOptimizer.h.

◆ Pointer

Definition at line 62 of file itkPreconditionedGradientDescentOptimizer.h.

◆ PreconditionType

Definition at line 85 of file itkPreconditionedGradientDescentOptimizer.h.

◆ PreconditionValueType

Some typedefs for computing the SelfHessian

Definition at line 81 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ScaledCostFunctionPointer

typedef Superclass::ScaledCostFunctionPointer itk::PreconditionedGradientDescentOptimizer::ScaledCostFunctionPointer

Definition at line 78 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ScaledCostFunctionType

typedef Superclass::ScaledCostFunctionType itk::PreconditionedGradientDescentOptimizer::ScaledCostFunctionType

Definition at line 77 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ScalesType

Definition at line 76 of file itkPreconditionedGradientDescentOptimizer.h.

◆ Self

Standard class typedefs.

Definition at line 60 of file itkPreconditionedGradientDescentOptimizer.h.

◆ Superclass

Definition at line 61 of file itkPreconditionedGradientDescentOptimizer.h.

Member Enumeration Documentation

◆ StopConditionType

Codes of stopping conditions The MinimumStepSize stopcondition never occurs, but may be implemented in inheriting classes.

Enumerator
MaximumNumberOfIterations 
MetricError 
MinimumStepSize 

Definition at line 91 of file itkPreconditionedGradientDescentOptimizer.h.

Constructor & Destructor Documentation

◆ PreconditionedGradientDescentOptimizer() [1/2]

itk::PreconditionedGradientDescentOptimizer::PreconditionedGradientDescentOptimizer ( )
protected

◆ ~PreconditionedGradientDescentOptimizer()

virtual itk::PreconditionedGradientDescentOptimizer::~PreconditionedGradientDescentOptimizer ( )
protectedvirtual

◆ PreconditionedGradientDescentOptimizer() [2/2]

itk::PreconditionedGradientDescentOptimizer::PreconditionedGradientDescentOptimizer ( const Self )
private

Member Function Documentation

◆ AdvanceOneStep()

virtual void itk::PreconditionedGradientDescentOptimizer::AdvanceOneStep ( void  )
virtual

Advance one step following the gradient direction.

Reimplemented in itk::StochasticPreconditionedGradientDescentOptimizer.

◆ CholmodSolve()

virtual void itk::PreconditionedGradientDescentOptimizer::CholmodSolve ( const DerivativeType gradient,
DerivativeType searchDirection,
int  solveType = CHOLMOD_A 
)
protectedvirtual

Solve Hx = g, using the Cholesky decomposition of the preconditioner. Matlab notation: x = L'(L\g) = Pg = searchDirection The last argument can be used to also solve different systems, like L x = g.

◆ GetCholmodCommon()

const cholmod_common * itk::PreconditionedGradientDescentOptimizer::GetCholmodCommon ( void  ) const
inline

Temporary functions, for debugging

Definition at line 150 of file itkPreconditionedGradientDescentOptimizer.h.

◆ GetCholmodFactor()

const cholmod_factor * itk::PreconditionedGradientDescentOptimizer::GetCholmodFactor ( void  ) const
inline

Definition at line 156 of file itkPreconditionedGradientDescentOptimizer.h.

◆ GetClassName()

virtual const char * itk::PreconditionedGradientDescentOptimizer::GetClassName ( ) const
virtual

◆ GetConditionNumber()

virtual double itk::PreconditionedGradientDescentOptimizer::GetConditionNumber ( ) const
virtual

Get estimated condition number; only valid after calling SetPreconditionMatrix

◆ GetCurrentIteration()

virtual unsigned int itk::PreconditionedGradientDescentOptimizer::GetCurrentIteration ( ) const
virtual

Get the current iteration number.

◆ GetDiagonalWeight()

virtual double itk::PreconditionedGradientDescentOptimizer::GetDiagonalWeight ( ) const
virtual

◆ GetGradient()

virtual const DerivativeType & itk::PreconditionedGradientDescentOptimizer::GetGradient ( )
virtual

Get current gradient.

◆ GetLargestEigenValue()

virtual double itk::PreconditionedGradientDescentOptimizer::GetLargestEigenValue ( ) const
virtual

Get largestEigenValue; only valid after calling SetPreconditionMatrix

◆ GetLearningRate()

virtual const double & itk::PreconditionedGradientDescentOptimizer::GetLearningRate ( )
virtual

Get the learning rate.

◆ GetMinimumGradientElementMagnitude()

virtual double itk::PreconditionedGradientDescentOptimizer::GetMinimumGradientElementMagnitude ( ) const
virtual

◆ GetNumberOfIterations()

virtual const unsigned long & itk::PreconditionedGradientDescentOptimizer::GetNumberOfIterations ( )
virtual

Get the number of iterations.

◆ GetSearchDirection()

virtual const DerivativeType & itk::PreconditionedGradientDescentOptimizer::GetSearchDirection ( )
virtual

Get current search direction

◆ GetSparsity()

virtual double itk::PreconditionedGradientDescentOptimizer::GetSparsity ( ) const
virtual

Get sparsity of selfhessian; only valid after calling SetPreconditionMatrix; Takes into account that only upper half of the matrix is stored. 1 = dense, 0 = all elements zero.

◆ GetStopCondition()

virtual const StopConditionType & itk::PreconditionedGradientDescentOptimizer::GetStopCondition ( )
virtual

Get Stop condition.

◆ GetValue()

virtual const double & itk::PreconditionedGradientDescentOptimizer::GetValue ( )
virtual

Get the current value.

◆ MetricErrorResponse()

virtual void itk::PreconditionedGradientDescentOptimizer::MetricErrorResponse ( ExceptionObject &  err)
virtual

Stop optimization and pass on exception.

◆ New()

static Pointer itk::PreconditionedGradientDescentOptimizer::New ( )
static

Method for creation through the object factory.

◆ operator=()

void itk::PreconditionedGradientDescentOptimizer::operator= ( const Self )
private

◆ PrintSelf()

void itk::PreconditionedGradientDescentOptimizer::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
protected

◆ ResumeOptimization()

virtual void itk::PreconditionedGradientDescentOptimizer::ResumeOptimization ( void  )
virtual

Resume previously stopped optimization with current parameters

See also
StopOptimization.

Reimplemented in elastix::PreconditionedGradientDescent< TElastix >.

◆ SetDiagonalWeight()

virtual void itk::PreconditionedGradientDescentOptimizer::SetDiagonalWeight ( double  _arg)
virtual

P = P + diagonalWeight * max(eigenvalue) * Identity

◆ SetLearningRate()

virtual void itk::PreconditionedGradientDescentOptimizer::SetLearningRate ( double  _arg)
virtual

Set the learning rate.

◆ SetMinimumGradientElementMagnitude()

virtual void itk::PreconditionedGradientDescentOptimizer::SetMinimumGradientElementMagnitude ( double  _arg)
virtual

Threshold for elements of cost function derivative; default 1e-10

◆ SetNumberOfIterations()

virtual void itk::PreconditionedGradientDescentOptimizer::SetNumberOfIterations ( unsigned long  _arg)
virtual

Set the number of iterations.

◆ SetPreconditionMatrix()

virtual void itk::PreconditionedGradientDescentOptimizer::SetPreconditionMatrix ( PreconditionType precondition)
virtual

Set the preconditioning matrix, whose inverse actually will be used to precondition. On setting the precondition matrix, an eigensystem is computed immediately, the eigenvalues/vectors are modified and only the modified eigenvectors/values are stored (in the EigenSystem). NB: this function destroys the input matrix, to save memory.

◆ StartOptimization()

virtual void itk::PreconditionedGradientDescentOptimizer::StartOptimization ( void  )
virtual

◆ StopOptimization()

virtual void itk::PreconditionedGradientDescentOptimizer::StopOptimization ( void  )
virtual

Stop optimization.

See also
ResumeOptimization

Field Documentation

◆ m_CholmodCommon

cholmod_common* itk::PreconditionedGradientDescentOptimizer::m_CholmodCommon
protected

Definition at line 201 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CholmodFactor

cholmod_factor* itk::PreconditionedGradientDescentOptimizer::m_CholmodFactor
protected

Definition at line 202 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CholmodGradient

cholmod_sparse* itk::PreconditionedGradientDescentOptimizer::m_CholmodGradient
protected

Definition at line 203 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_ConditionNumber

double itk::PreconditionedGradientDescentOptimizer::m_ConditionNumber
protected

Definition at line 198 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CurrentIteration

unsigned long itk::PreconditionedGradientDescentOptimizer::m_CurrentIteration
private

Definition at line 220 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_DiagonalWeight

double itk::PreconditionedGradientDescentOptimizer::m_DiagonalWeight
private

Definition at line 222 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Gradient

DerivativeType itk::PreconditionedGradientDescentOptimizer::m_Gradient
protected

Definition at line 193 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_LargestEigenValue

double itk::PreconditionedGradientDescentOptimizer::m_LargestEigenValue
protected

Definition at line 197 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_LearningRate

double itk::PreconditionedGradientDescentOptimizer::m_LearningRate
protected

Definition at line 194 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_MinimumGradientElementMagnitude

double itk::PreconditionedGradientDescentOptimizer::m_MinimumGradientElementMagnitude
private

Definition at line 223 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_NumberOfIterations

unsigned long itk::PreconditionedGradientDescentOptimizer::m_NumberOfIterations
private

Definition at line 219 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_SearchDirection

DerivativeType itk::PreconditionedGradientDescentOptimizer::m_SearchDirection
protected

Definition at line 196 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Sparsity

double itk::PreconditionedGradientDescentOptimizer::m_Sparsity
protected

Definition at line 199 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Stop

bool itk::PreconditionedGradientDescentOptimizer::m_Stop
private

Definition at line 216 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_StopCondition

StopConditionType itk::PreconditionedGradientDescentOptimizer::m_StopCondition
protected

Definition at line 195 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Value

double itk::PreconditionedGradientDescentOptimizer::m_Value
private

Definition at line 217 of file itkPreconditionedGradientDescentOptimizer.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo