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 Member Functions | Protected Attributes | Private Member Functions | Private Attributes
itk::StandardStochasticGradientOptimizer Class Reference

#include <itkStandardStochasticGradientDescentOptimizer.h>

Detailed Description

This class implements a gradient descent optimizer with a decaying gain.

If $C(x)$ is a costfunction that has to be minimised, the following iterative algorithm is used to find the optimal parameters $x$:

\[ x(k+1) = x(k) - a(k) dC/dx \]

The gain $a(k)$ at each iteration $k$ is defined by:

\[ a(k) =  a / (A + k + 1)^alpha \]

.

It is very suitable to be used in combination with a stochastic estimate of the gradient $dC/dx$. For example, in image registration problems it is often advantageous to compute the metric derivative ( $dC/dx$) on a new set of randomly selected image samples in each iteration. You may set the parameter NewSamplesEveryIteration to "true" to achieve this effect. For more information on this strategy, you may have a look at:

S. Klein, M. Staring, J.P.W. Pluim, "Comparison of gradient approximation techniques for optimisation of mutual information in nonrigid registration", in: SPIE Medical Imaging: Image Processing, Editor(s): J.M. Fitzpatrick, J.M. Reinhardt, SPIE press, 2005, vol. 5747, Proceedings of SPIE, pp. 192-203.

Or:

S. Klein, M. Staring, J.P.W. Pluim, "Evaluation of Optimization Methods for Nonrigid Medical Image Registration using Mutual Information and B-Splines" IEEE Transactions on Image Processing, 2007, nr. 16(12), December.

This class also serves as a base class for other StochasticGradient type algorithms, like the AcceleratedStochasticGradientOptimizer.

See also
StandardStochasticGradient, AcceleratedStochasticGradientOptimizer

Definition at line 64 of file itkStandardStochasticGradientDescentOptimizer.h.

+ Inheritance diagram for itk::StandardStochasticGradientOptimizer:

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 Superclass::ScaledCostFunctionPointer ScaledCostFunctionPointer
 
typedef Superclass::ScaledCostFunctionType ScaledCostFunctionType
 
typedef Superclass::ScalesType ScalesType
 
typedef StandardStochasticGradientOptimizer Self
 
typedef Superclass::StopConditionType StopConditionType
 
typedef StochasticGradientDescentOptimizer Superclass
 
- Public Types inherited from itk::StochasticGradientDescentOptimizer
typedef SmartPointer< const SelfConstPointer
 
typedef Superclass::CostFunctionType CostFunctionType
 
typedef Superclass::DerivativeType DerivativeType
 
typedef Superclass::MeasureType MeasureType
 
typedef Superclass::ParametersType ParametersType
 
typedef SmartPointer< SelfPointer
 
typedef Superclass::ScaledCostFunctionPointer ScaledCostFunctionPointer
 
typedef Superclass::ScaledCostFunctionType ScaledCostFunctionType
 
typedef Superclass::ScalesType ScalesType
 
typedef StochasticGradientDescentOptimizer Self
 
enum  StopConditionType {
  MaximumNumberOfIterations , MetricError , MinimumStepSize , InvalidDiagonalMatrix ,
  GradientMagnitudeTolerance , LineSearchError
}
 
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

void AdvanceOneStep (void) override
 
virtual const char * GetClassName () const
 
virtual double GetCurrentTime () const
 
virtual double GetInitialTime () const
 
virtual double GetParam_a () const
 
virtual double GetParam_A () const
 
virtual double GetParam_alpha () const
 
virtual double GetParam_beta () const
 
virtual void ResetCurrentTimeToInitialTime (void)
 
virtual void SetInitialTime (double _arg)
 
virtual void SetParam_a (double _arg)
 
virtual void SetParam_A (double _arg)
 
virtual void SetParam_alpha (double _arg)
 
virtual void SetParam_beta (double _arg)
 
void StartOptimization (void) override
 
- Public Member Functions inherited from itk::StochasticGradientDescentOptimizer
virtual void AdvanceOneStep (void)
 
virtual const char * GetClassName () const
 
virtual unsigned int GetCurrentInnerIteration () const
 
virtual unsigned int GetCurrentIteration () const
 
virtual const DerivativeTypeGetGradient ()
 
virtual unsigned int GetLBFGSMemory () const
 
virtual const doubleGetLearningRate ()
 
virtual const unsigned long & GetNumberOfInnerIterations ()
 
virtual const unsigned long & GetNumberOfIterations ()
 
virtual const DerivativeTypeGetPreviousGradient ()
 
virtual const ParametersTypeGetPreviousPosition ()
 
virtual const DerivativeTypeGetSearchDir ()
 
virtual const StopConditionTypeGetStopCondition ()
 
virtual const doubleGetValue ()
 
virtual void MetricErrorResponse (ExceptionObject &err)
 
virtual void ResumeOptimization (void)
 
virtual void SetLearningRate (double _arg)
 
virtual void SetNumberOfIterations (unsigned long _arg)
 
void SetNumberOfWorkUnits (ThreadIdType numberOfThreads)
 
virtual void SetPreviousGradient (DerivativeType _arg)
 
virtual void SetPreviousPosition (ParametersType _arg)
 
virtual void SetUseEigen (bool _arg)
 
virtual void SetUseMultiThread (bool _arg)
 
virtual void SetUseOpenMP (bool _arg)
 
void StartOptimization (void) override
 
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::StochasticGradientDescentOptimizer
static Pointer New ()
 
- Static Public Member Functions inherited from itk::ScaledSingleValuedNonLinearOptimizer
static Pointer New ()
 

Protected Member Functions

virtual double Compute_a (double k) const
 
virtual double Compute_beta (double k) const
 
 StandardStochasticGradientOptimizer ()
 
virtual void UpdateCurrentTime (void)
 
 ~StandardStochasticGradientOptimizer () override
 
- Protected Member Functions inherited from itk::StochasticGradientDescentOptimizer
void PrintSelf (std::ostream &os, Indent indent) const override
 
 StochasticGradientDescentOptimizer ()
 
 ~StochasticGradientDescentOptimizer () override
 
- 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

double m_CurrentTime
 
bool m_UseConstantStep
 
- Protected Attributes inherited from itk::StochasticGradientDescentOptimizer
unsigned long m_CurrentInnerIteration
 
unsigned long m_CurrentIteration
 
DerivativeType m_Gradient
 
unsigned long m_LBFGSMemory
 
double m_LearningRate
 
ParametersType m_MeanSearchDir
 
unsigned long m_NumberOfInnerIterations
 
unsigned long m_NumberOfIterations
 
DerivativeType m_PrePreviousGradient
 
ParametersType m_PrePreviousSearchDir
 
DerivativeType m_PreviousGradient
 
ParametersType m_PreviousPosition
 
ParametersType m_PreviousSearchDir
 
ParametersType m_SearchDir
 
bool m_Stop
 
StopConditionType m_StopCondition
 
ThreaderType::Pointer m_Threader
 
double m_Value
 
- Protected Attributes inherited from itk::ScaledSingleValuedNonLinearOptimizer
ScaledCostFunctionPointer m_ScaledCostFunction
 
ParametersType m_ScaledCurrentPosition
 

Private Member Functions

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

Private Attributes

double m_InitialTime
 
double m_Param_a
 
double m_Param_A
 
double m_Param_alpha
 
double m_Param_beta
 

Additional Inherited Members

- Protected Types inherited from itk::StochasticGradientDescentOptimizer
typedef itk::PlatformMultiThreader ThreaderType
 
typedef ThreaderType::WorkUnitInfo ThreadInfoType
 

Member Typedef Documentation

◆ ConstPointer

◆ CostFunctionType

typedef Superclass::CostFunctionType itk::StandardStochasticGradientOptimizer::CostFunctionType

◆ DerivativeType

◆ MeasureType

Typedefs inherited from the superclass.

Definition at line 82 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ ParametersType

◆ Pointer

◆ ScaledCostFunctionPointer

typedef Superclass::ScaledCostFunctionPointer itk::StandardStochasticGradientOptimizer::ScaledCostFunctionPointer

◆ ScaledCostFunctionType

typedef Superclass::ScaledCostFunctionType itk::StandardStochasticGradientOptimizer::ScaledCostFunctionType

◆ ScalesType

◆ Self

Standard ITK.

Definition at line 70 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ StopConditionType

typedef Superclass::StopConditionType itk::StandardStochasticGradientOptimizer::StopConditionType

◆ Superclass

Constructor & Destructor Documentation

◆ StandardStochasticGradientOptimizer() [1/2]

itk::StandardStochasticGradientOptimizer::StandardStochasticGradientOptimizer ( )
protected

◆ ~StandardStochasticGradientOptimizer()

itk::StandardStochasticGradientOptimizer::~StandardStochasticGradientOptimizer ( )
inlineoverrideprotected

◆ StandardStochasticGradientOptimizer() [2/2]

itk::StandardStochasticGradientOptimizer::StandardStochasticGradientOptimizer ( const Self )
private

Member Function Documentation

◆ AdvanceOneStep()

void itk::StandardStochasticGradientOptimizer::AdvanceOneStep ( void  )
overridevirtual

Sets a new LearningRate before calling the Superclass' implementation, and updates the current time.

Reimplemented from itk::StochasticGradientDescentOptimizer.

◆ Compute_a()

virtual double itk::StandardStochasticGradientOptimizer::Compute_a ( double  k) const
protectedvirtual

Function to compute the step size for SGD at time/iteration k.

◆ Compute_beta()

virtual double itk::StandardStochasticGradientOptimizer::Compute_beta ( double  k) const
protectedvirtual

Function to compute the step size for SQN at time/iteration k.

◆ GetClassName()

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

Run-time type information (and related methods).

Reimplemented from itk::StochasticGradientDescentOptimizer.

Reimplemented in elastix::AdaptiveStochasticLBFGS< TElastix >, and itk::AdaptiveStochasticLBFGSOptimizer.

◆ GetCurrentTime()

virtual double itk::StandardStochasticGradientOptimizer::GetCurrentTime ( ) const
virtual

Get the current time. This equals the CurrentIteration in this base class but may be different in inheriting classes, such as the AccelerateStochasticGradient

◆ GetInitialTime()

virtual double itk::StandardStochasticGradientOptimizer::GetInitialTime ( ) const
virtual

◆ GetParam_a()

virtual double itk::StandardStochasticGradientOptimizer::GetParam_a ( ) const
virtual

◆ GetParam_A()

virtual double itk::StandardStochasticGradientOptimizer::GetParam_A ( ) const
virtual

◆ GetParam_alpha()

virtual double itk::StandardStochasticGradientOptimizer::GetParam_alpha ( ) const
virtual

◆ GetParam_beta()

virtual double itk::StandardStochasticGradientOptimizer::GetParam_beta ( ) const
virtual

◆ New()

static Pointer itk::StandardStochasticGradientOptimizer::New ( )
static

Method for creation through the object factory.

◆ operator=()

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

◆ ResetCurrentTimeToInitialTime()

virtual void itk::StandardStochasticGradientOptimizer::ResetCurrentTimeToInitialTime ( void  )
inlinevirtual

Set the current time to the initial time. This can be useful to 'reset' the optimisation, for example if you changed the cost function while optimisation. Be careful with this function.

Definition at line 129 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ SetInitialTime()

virtual void itk::StandardStochasticGradientOptimizer::SetInitialTime ( double  _arg)
virtual

Set/Get the initial time. Should be >=0. This function is superfluous, since Param_A does effectively the same. However, in inheriting classes, like the AcceleratedStochasticGradient the initial time may have a different function than Param_A. Default: 0.0

◆ SetParam_a()

virtual void itk::StandardStochasticGradientOptimizer::SetParam_a ( double  _arg)
virtual

Set/Get a.

◆ SetParam_A()

virtual void itk::StandardStochasticGradientOptimizer::SetParam_A ( double  _arg)
virtual

Set/Get A.

◆ SetParam_alpha()

virtual void itk::StandardStochasticGradientOptimizer::SetParam_alpha ( double  _arg)
virtual

Set/Get alpha.

◆ SetParam_beta()

virtual void itk::StandardStochasticGradientOptimizer::SetParam_beta ( double  _arg)
virtual

Set/Get beta.

◆ StartOptimization()

void itk::StandardStochasticGradientOptimizer::StartOptimization ( void  )
override

Set current time to 0 and call superclass' implementation.

◆ UpdateCurrentTime()

virtual void itk::StandardStochasticGradientOptimizer::UpdateCurrentTime ( void  )
protectedvirtual

Function to update the current time This function just increments the CurrentTime by 1. Inheriting functions may implement something smarter, for example, dependent on the progress

Reimplemented in itk::AdaptiveStochasticLBFGSOptimizer.

Field Documentation

◆ m_CurrentTime

double itk::StandardStochasticGradientOptimizer::m_CurrentTime
protected

The current time, which serves as input for Compute_a

Definition at line 152 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ m_InitialTime

double itk::StandardStochasticGradientOptimizer::m_InitialTime
private

Settings

Definition at line 169 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ m_Param_a

double itk::StandardStochasticGradientOptimizer::m_Param_a
private

Parameters, as described by Spall.

Definition at line 163 of file itkStandardStochasticGradientDescentOptimizer.h.

◆ m_Param_A

double itk::StandardStochasticGradientOptimizer::m_Param_A
private

◆ m_Param_alpha

double itk::StandardStochasticGradientOptimizer::m_Param_alpha
private

◆ m_Param_beta

double itk::StandardStochasticGradientOptimizer::m_Param_beta
private

◆ m_UseConstantStep

bool itk::StandardStochasticGradientOptimizer::m_UseConstantStep
protected

Constant step size or others, different value of k.

Definition at line 155 of file itkStandardStochasticGradientDescentOptimizer.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo