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 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:
Inheritance graph
[legend]

Public Types

using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using PreconditionType = vnl_sparse_matrix< PreconditionValueType >
 
using PreconditionValueType = DerivativeType::ValueType
 
using ScaledCostFunctionPointer = ScaledCostFunctionType::Pointer
 
using ScaledCostFunctionType = ScaledSingleValuedCostFunction
 
using ScalesType = NonLinearOptimizer::ScalesType
 
using Self = PreconditionedGradientDescentOptimizer
 
enum  StopConditionType { MaximumNumberOfIterations , MetricError , MinimumStepSize }
 
using Superclass = ScaledSingleValuedNonLinearOptimizer
 
- Public Types inherited from itk::ScaledSingleValuedNonLinearOptimizer
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using ScaledCostFunctionPointer = ScaledCostFunctionType::Pointer
 
using ScaledCostFunctionType = ScaledSingleValuedCostFunction
 
using ScalesType = NonLinearOptimizer::ScalesType
 
using Self = ScaledSingleValuedNonLinearOptimizer
 
using Superclass = SingleValuedNonLinearOptimizer
 

Public Member Functions

virtual void AdvanceOneStep ()
 
const cholmod_common * GetCholmodCommon () const
 
const cholmod_factor * GetCholmodFactor () const
 
virtual const char * GetClassName () const
 
virtual double GetConditionNumber () const
 
virtual unsigned int GetCurrentIteration () const
 
virtual double GetDiagonalWeight () const
 
virtual const DerivativeType & GetGradient ()
 
virtual double GetLargestEigenValue () const
 
virtual const doubleGetLearningRate ()
 
virtual double GetMinimumGradientElementMagnitude () const
 
virtual const unsigned long & GetNumberOfIterations ()
 
virtual const DerivativeType & GetSearchDirection ()
 
virtual double GetSparsity () const
 
virtual const StopConditionTypeGetStopCondition ()
 
virtual const doubleGetValue ()
 
 ITK_DISALLOW_COPY_AND_MOVE (PreconditionedGradientDescentOptimizer)
 
virtual void MetricErrorResponse (ExceptionObject &err)
 
virtual void ResumeOptimization ()
 
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 ()
 
virtual void StopOptimization ()
 
- Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
virtual const char * GetClassName () const
 
const ParametersType & GetCurrentPosition () const override
 
virtual bool GetMaximize () const
 
virtual const ScaledCostFunctionTypeGetScaledCostFunction ()
 
virtual const ParametersType & GetScaledCurrentPosition ()
 
bool GetUseScales () const
 
virtual void InitializeScales ()
 
 ITK_DISALLOW_COPY_AND_MOVE (ScaledSingleValuedNonLinearOptimizer)
 
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

using cholmod_l = 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=default
 

Protected Attributes

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

Private Attributes

unsigned long m_CurrentIteration { 0 }
 
double m_DiagonalWeight { 1e-6 }
 
double m_MinimumGradientElementMagnitude { 1e-10 }
 
unsigned long m_NumberOfIterations { 100 }
 
bool m_Stop { false }
 
double m_Value { 0.0 }
 

Member Typedef Documentation

◆ cholmod_l

Cholmod index type: define at central place

Definition at line 202 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ConstPointer

Definition at line 64 of file itkPreconditionedGradientDescentOptimizer.h.

◆ Pointer

Definition at line 63 of file itkPreconditionedGradientDescentOptimizer.h.

◆ PreconditionType

Definition at line 86 of file itkPreconditionedGradientDescentOptimizer.h.

◆ PreconditionValueType

Some typedefs for computing the SelfHessian

Definition at line 82 of file itkPreconditionedGradientDescentOptimizer.h.

◆ ScaledCostFunctionPointer

Definition at line 87 of file itkScaledSingleValuedNonLinearOptimizer.h.

◆ ScaledCostFunctionType

Definition at line 86 of file itkScaledSingleValuedNonLinearOptimizer.h.

◆ ScalesType

using itk::ScaledSingleValuedNonLinearOptimizer::ScalesType = NonLinearOptimizer::ScalesType

Definition at line 85 of file itkScaledSingleValuedNonLinearOptimizer.h.

◆ Self

Standard class typedefs.

Definition at line 61 of file itkPreconditionedGradientDescentOptimizer.h.

◆ Superclass

Definition at line 62 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 92 of file itkPreconditionedGradientDescentOptimizer.h.

Constructor & Destructor Documentation

◆ PreconditionedGradientDescentOptimizer()

itk::PreconditionedGradientDescentOptimizer::PreconditionedGradientDescentOptimizer ( )
protected

◆ ~PreconditionedGradientDescentOptimizer()

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

Member Function Documentation

◆ AdvanceOneStep()

virtual void itk::PreconditionedGradientDescentOptimizer::AdvanceOneStep ( )
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 ( ) const
inline

Temporary functions, for debugging

Definition at line 160 of file itkPreconditionedGradientDescentOptimizer.h.

◆ GetCholmodFactor()

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

Definition at line 167 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.

◆ ITK_DISALLOW_COPY_AND_MOVE()

itk::PreconditionedGradientDescentOptimizer::ITK_DISALLOW_COPY_AND_MOVE ( PreconditionedGradientDescentOptimizer  )

◆ 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.

◆ PrintSelf()

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

◆ ResumeOptimization()

virtual void itk::PreconditionedGradientDescentOptimizer::ResumeOptimization ( )
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 ( )
virtual

◆ StopOptimization()

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

Stop optimization.

See also
ResumeOptimization

Field Documentation

◆ m_CholmodCommon

cholmod_common* itk::PreconditionedGradientDescentOptimizer::m_CholmodCommon
protected

Definition at line 213 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CholmodFactor

cholmod_factor* itk::PreconditionedGradientDescentOptimizer::m_CholmodFactor { nullptr }
protected

Definition at line 214 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CholmodGradient

cholmod_sparse* itk::PreconditionedGradientDescentOptimizer::m_CholmodGradient { nullptr }
protected

Definition at line 215 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_ConditionNumber

double itk::PreconditionedGradientDescentOptimizer::m_ConditionNumber { 1.0 }
protected

Definition at line 210 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_CurrentIteration

unsigned long itk::PreconditionedGradientDescentOptimizer::m_CurrentIteration { 0 }
private

Definition at line 229 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_DiagonalWeight

double itk::PreconditionedGradientDescentOptimizer::m_DiagonalWeight { 1e-6 }
private

Definition at line 231 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Gradient

DerivativeType itk::PreconditionedGradientDescentOptimizer::m_Gradient
protected

Definition at line 205 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_LargestEigenValue

double itk::PreconditionedGradientDescentOptimizer::m_LargestEigenValue { 1.0 }
protected

Definition at line 209 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_LearningRate

double itk::PreconditionedGradientDescentOptimizer::m_LearningRate { 1.0 }
protected

Definition at line 206 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_MinimumGradientElementMagnitude

double itk::PreconditionedGradientDescentOptimizer::m_MinimumGradientElementMagnitude { 1e-10 }
private

Definition at line 232 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_NumberOfIterations

unsigned long itk::PreconditionedGradientDescentOptimizer::m_NumberOfIterations { 100 }
private

Definition at line 228 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_SearchDirection

DerivativeType itk::PreconditionedGradientDescentOptimizer::m_SearchDirection
protected

Definition at line 208 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Sparsity

double itk::PreconditionedGradientDescentOptimizer::m_Sparsity { 1.0 }
protected

Definition at line 211 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Stop

bool itk::PreconditionedGradientDescentOptimizer::m_Stop { false }
private

Definition at line 225 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_StopCondition

StopConditionType itk::PreconditionedGradientDescentOptimizer::m_StopCondition { MaximumNumberOfIterations }
protected

Definition at line 207 of file itkPreconditionedGradientDescentOptimizer.h.

◆ m_Value

double itk::PreconditionedGradientDescentOptimizer::m_Value { 0.0 }
private

Definition at line 226 of file itkPreconditionedGradientDescentOptimizer.h.



Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo