Loading...
Searching...
No Matches
itkStochasticVarianceReducedGradientDescentOptimizer.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkStochasticVarianceReducedGradientDescentOptimizer_h
#define itkStochasticVarianceReducedGradientDescentOptimizer_h
#include "itkScaledSingleValuedNonLinearOptimizer.h"
#include "itkMultiThreaderBase.h"
namespace itk
{
class StochasticVarianceReducedGradientDescentOptimizer : public ScaledSingleValuedNonLinearOptimizer
{
public:
ITK_DISALLOW_COPY_AND_MOVE(StochasticVarianceReducedGradientDescentOptimizer);
using Self = StochasticVarianceReducedGradientDescentOptimizer;
using Superclass = ScaledSingleValuedNonLinearOptimizer;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(StochasticVarianceReducedGradientDescentOptimizer, ScaledSingleValuedNonLinearOptimizer);
using Superclass::MeasureType;
using Superclass::ParametersType;
using Superclass::DerivativeType;
using Superclass::CostFunctionType;
using Superclass::ScalesType;
using Superclass::ScaledCostFunctionType;
using Superclass::ScaledCostFunctionPointer;
enum StopConditionType
{
MaximumNumberOfIterations,
MetricError,
MinimumStepSize,
InvalidDiagonalMatrix,
GradientMagnitudeTolerance,
LineSearchError
};
virtual void
AdvanceOneStep();
void
StartOptimization() override;
virtual void
ResumeOptimization();
virtual void
MetricErrorResponse(ExceptionObject & err);
virtual void
StopOptimization();
itkSetMacro(LearningRate, double);
itkGetConstReferenceMacro(LearningRate, double);
itkSetMacro(NumberOfIterations, unsigned long);
itkGetConstMacro(LBFGSMemory, unsigned int);
itkGetConstReferenceMacro(NumberOfIterations, unsigned long);
itkGetConstReferenceMacro(NumberOfInnerIterations, unsigned long);
itkGetConstMacro(CurrentIteration, unsigned int);
itkGetConstMacro(CurrentInnerIteration, unsigned int);
itkGetConstReferenceMacro(Value, double);
itkGetConstReferenceMacro(StopCondition, StopConditionType);
itkGetConstReferenceMacro(Gradient, DerivativeType);
itkGetConstReferenceMacro(SearchDir, DerivativeType);
itkSetMacro(PreviousPosition, ParametersType);
itkGetConstReferenceMacro(PreviousPosition, ParametersType);
itkSetMacro(PreviousGradient, DerivativeType);
itkGetConstReferenceMacro(PreviousGradient, DerivativeType);
void
SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
{
this->m_Threader->SetNumberOfWorkUnits(numberOfThreads);
}
// itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
itkSetMacro(UseMultiThread, bool);
itkSetMacro(UseEigen, bool);
protected:
StochasticVarianceReducedGradientDescentOptimizer();
~StochasticVarianceReducedGradientDescentOptimizer() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;
using ThreadInfoType = MultiThreaderBase::WorkUnitInfo;
// made protected so subclass can access
double m_Value{ 0.0 };
DerivativeType m_Gradient{};
ParametersType m_SearchDir{};
ParametersType m_PreviousSearchDir{};
// ParametersType m_PrePreviousSearchDir;
ParametersType m_MeanSearchDir{};
double m_LearningRate{ 1.0 };
StopConditionType m_StopCondition{ MaximumNumberOfIterations };
DerivativeType m_PreviousGradient{};
// DerivativeType m_PrePreviousGradient;
ParametersType m_PreviousPosition{};
MultiThreaderBase::Pointer m_Threader{ MultiThreaderBase::New() };
bool m_Stop{ false };
unsigned long m_NumberOfIterations{ 100 };
unsigned long m_NumberOfInnerIterations{};
unsigned long m_CurrentIteration{ 0 };
unsigned long m_CurrentInnerIteration{};
unsigned long m_LBFGSMemory{ 0 };
private:
// multi-threaded AdvanceOneStep:
bool m_UseMultiThread{ false };
struct MultiThreaderParameterType
{
ParametersType * t_NewPosition;
Self * t_Optimizer;
};
bool m_UseEigen{ false };
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
AdvanceOneStepThreaderCallback(void * arg);
inline void
ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType & newPosition);
};
} // end namespace itk
#endif
itk::ScaledSingleValuedNonLinearOptimizer::ScaledSingleValuedNonLinearOptimizer
ScaledSingleValuedNonLinearOptimizer()
itk::ScaledSingleValuedNonLinearOptimizer::ScaledCostFunctionPointer
ScaledCostFunctionType::Pointer ScaledCostFunctionPointer
Definition itkScaledSingleValuedNonLinearOptimizer.h:87
itk::ScaledSingleValuedNonLinearOptimizer::ScalesType
NonLinearOptimizer::ScalesType ScalesType
Definition itkScaledSingleValuedNonLinearOptimizer.h:85
itk::ScaledSingleValuedNonLinearOptimizer::ScaledCostFunctionType
ScaledSingleValuedCostFunction ScaledCostFunctionType
Definition itkScaledSingleValuedNonLinearOptimizer.h:86
itk::StochasticVarianceReducedGradientDescentOptimizer::StartOptimization
void StartOptimization() override
itk::StochasticVarianceReducedGradientDescentOptimizer::m_PreviousSearchDir
ParametersType m_PreviousSearchDir
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:184
itk::StochasticVarianceReducedGradientDescentOptimizer::MetricErrorResponse
virtual void MetricErrorResponse(ExceptionObject &err)
itk::StochasticVarianceReducedGradientDescentOptimizer::m_UseEigen
bool m_UseEigen
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:210
itk::StochasticVarianceReducedGradientDescentOptimizer::m_MeanSearchDir
ParametersType m_MeanSearchDir
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:186
itk::StochasticVarianceReducedGradientDescentOptimizer::Superclass
ScaledSingleValuedNonLinearOptimizer Superclass
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:59
itk::StochasticVarianceReducedGradientDescentOptimizer::~StochasticVarianceReducedGradientDescentOptimizer
~StochasticVarianceReducedGradientDescentOptimizer() override=default
itk::StochasticVarianceReducedGradientDescentOptimizer::m_CurrentInnerIteration
unsigned long m_CurrentInnerIteration
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:198
itk::StochasticVarianceReducedGradientDescentOptimizer::m_UseMultiThread
bool m_UseMultiThread
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:203
itk::StochasticVarianceReducedGradientDescentOptimizer::m_PreviousGradient
DerivativeType m_PreviousGradient
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:189
itk::StochasticVarianceReducedGradientDescentOptimizer::AdvanceOneStep
virtual void AdvanceOneStep()
itk::StochasticVarianceReducedGradientDescentOptimizer::m_PreviousPosition
ParametersType m_PreviousPosition
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:191
itk::StochasticVarianceReducedGradientDescentOptimizer::m_NumberOfInnerIterations
unsigned long m_NumberOfInnerIterations
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:196
itk::StochasticVarianceReducedGradientDescentOptimizer::ResumeOptimization
virtual void ResumeOptimization()
itk::StochasticVarianceReducedGradientDescentOptimizer::ThreadedAdvanceOneStep
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
itk::StochasticVarianceReducedGradientDescentOptimizer::ThreadInfoType
MultiThreaderBase::WorkUnitInfo ThreadInfoType
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:178
itk::StochasticVarianceReducedGradientDescentOptimizer::SetNumberOfWorkUnits
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:163
itk::StochasticVarianceReducedGradientDescentOptimizer::AdvanceOneStepThreaderCallback
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AdvanceOneStepThreaderCallback(void *arg)
itk::StochasticVarianceReducedGradientDescentOptimizer::StopConditionType
StopConditionType
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:82
itk::StochasticVarianceReducedGradientDescentOptimizer::MaximumNumberOfIterations
@ MaximumNumberOfIterations
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:83
itk::StochasticVarianceReducedGradientDescentOptimizer::LineSearchError
@ LineSearchError
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:88
itk::StochasticVarianceReducedGradientDescentOptimizer::InvalidDiagonalMatrix
@ InvalidDiagonalMatrix
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:86
itk::StochasticVarianceReducedGradientDescentOptimizer::GradientMagnitudeTolerance
@ GradientMagnitudeTolerance
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:87
itk::StochasticVarianceReducedGradientDescentOptimizer::MinimumStepSize
@ MinimumStepSize
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:85
itk::StochasticVarianceReducedGradientDescentOptimizer::MetricError
@ MetricError
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:84
itk::StochasticVarianceReducedGradientDescentOptimizer::m_Gradient
DerivativeType m_Gradient
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:182
itk::StochasticVarianceReducedGradientDescentOptimizer::StochasticVarianceReducedGradientDescentOptimizer
StochasticVarianceReducedGradientDescentOptimizer()
itk::StochasticVarianceReducedGradientDescentOptimizer::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(StochasticVarianceReducedGradientDescentOptimizer)
itk::StochasticVarianceReducedGradientDescentOptimizer::m_SearchDir
ParametersType m_SearchDir
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:183
itk::StochasticVarianceReducedGradientDescentOptimizer::Pointer
SmartPointer< Self > Pointer
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:60
itk::StochasticVarianceReducedGradientDescentOptimizer::m_CurrentIteration
unsigned long m_CurrentIteration
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:197
itk::StochasticVarianceReducedGradientDescentOptimizer::m_Threader
MultiThreaderBase::Pointer m_Threader
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:192
itk::StochasticVarianceReducedGradientDescentOptimizer::StopOptimization
virtual void StopOptimization()
itk::StochasticVarianceReducedGradientDescentOptimizer::m_Stop
bool m_Stop
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:194
itk::StochasticVarianceReducedGradientDescentOptimizer::Self
StochasticVarianceReducedGradientDescentOptimizer Self
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:58
itk::StochasticVarianceReducedGradientDescentOptimizer::m_StopCondition
StopConditionType m_StopCondition
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:188
itk::StochasticVarianceReducedGradientDescentOptimizer::m_NumberOfIterations
unsigned long m_NumberOfIterations
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:195
itk::StochasticVarianceReducedGradientDescentOptimizer::m_LBFGSMemory
unsigned long m_LBFGSMemory
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:199
itk::StochasticVarianceReducedGradientDescentOptimizer::m_LearningRate
double m_LearningRate
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:187
itk::StochasticVarianceReducedGradientDescentOptimizer::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:61
itk::StochasticVarianceReducedGradientDescentOptimizer::m_Value
double m_Value
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:181
itk::StochasticVarianceReducedGradientDescentOptimizer::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itkScaledSingleValuedNonLinearOptimizer.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::StochasticVarianceReducedGradientDescentOptimizer::MultiThreaderParameterType
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:205
itk::StochasticVarianceReducedGradientDescentOptimizer::MultiThreaderParameterType::t_NewPosition
ParametersType * t_NewPosition
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:206
itk::StochasticVarianceReducedGradientDescentOptimizer::MultiThreaderParameterType::t_Optimizer
Self * t_Optimizer
Definition itkStochasticVarianceReducedGradientDescentOptimizer.h:207

Generated on 1768596610 for elastix by 1.15.0 |