ITK  5.4.0
Insight Toolkit
itkGradientDescentOptimizerBasev4.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkGradientDescentOptimizerBasev4_h
19#define itkGradientDescentOptimizerBasev4_h
20
24#include "itkDomainThreader.h"
25
26namespace itk
27{
39template <typename TInternalComputationValueType>
41 : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
42{
43public:
44 ITK_DISALLOW_COPY_AND_MOVE(GradientDescentOptimizerBasev4Template);
45
51
53 itkOverrideGetNameOfClassMacro(GradientDescentOptimizerBasev4Template);
54
55#if !defined(ITK_LEGACY_REMOVE)
57 static constexpr itk::StopConditionObjectToObjectOptimizerEnum MAXIMUM_NUMBER_OF_ITERATIONS =
59 static constexpr itk::StopConditionObjectToObjectOptimizerEnum COSTFUNCTION_ERROR =
61 static constexpr itk::StopConditionObjectToObjectOptimizerEnum UPDATE_PARAMETERS_ERROR =
63 static constexpr itk::StopConditionObjectToObjectOptimizerEnum STEP_TOO_SMALL =
65 static constexpr itk::StopConditionObjectToObjectOptimizerEnum CONVERGENCE_CHECKER_PASSED =
67 static constexpr itk::StopConditionObjectToObjectOptimizerEnum GRADIENT_MAGNITUDE_TOLEARANCE =
69 static constexpr itk::StopConditionObjectToObjectOptimizerEnum OTHER_ERROR =
71#endif
72
74 using typename Superclass::StopConditionReturnStringType;
75
77 using typename Superclass::StopConditionDescriptionType;
78
80 using InternalComputationValueType = TInternalComputationValueType;
81
83 using typename Superclass::MetricType;
85
87 using typename Superclass::DerivativeType;
88
90 using typename Superclass::MeasureType;
91
92 using typename Superclass::ScalesType;
93
94 using typename Superclass::ParametersType;
95
98
100 itkGetConstReferenceMacro(Gradient, DerivativeType);
101
104
106 void
107 StartOptimization(bool doOnlyInitialization = false) override;
108
112 virtual void
114
117 virtual void
119
123
136 virtual void
138 virtual void
143
149 virtual void
151
160 virtual void
162
163protected:
172 bool m_DoEstimateLearningRateAtEachIteration{};
173
177 bool m_DoEstimateLearningRateOnce{};
178
185 TInternalComputationValueType m_MaximumStepSizeInPhysicalUnits{};
186
191 bool m_UseConvergenceMonitoring{};
192
197 SizeValueType m_ConvergenceWindowSize{};
198
200 typename ConvergenceMonitoringType::Pointer m_ConvergenceMonitoring{};
201
203 typename DomainThreader<ThreadedIndexedContainerPartitioner, Self>::Pointer m_ModifyGradientByLearningRateThreader{};
204
205 /* Common variables for optimization control and reporting */
206 bool m_Stop{ false };
208 StopConditionDescriptionType m_StopConditionDescription{};
209
211 DerivativeType m_Gradient{};
212 void
213 PrintSelf(std::ostream & os, Indent indent) const override;
214
215private:
216};
217
220
221} // end namespace itk
222
223#ifndef ITK_MANUAL_INSTANTIATION
224# include "itkGradientDescentOptimizerBasev4.hxx"
225#endif
226
227#endif
Class which monitors convergence during the course of optimization.
virtual void ModifyGradientByScalesOverSubRange(const IndexRangeType &subrange)=0
const StopConditionReturnStringType GetStopConditionDescription() const override
virtual void ModifyGradientByLearningRateOverSubRange(const IndexRangeType &subrange)=0
void StartOptimization(bool doOnlyInitialization=false) override
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
~GradientDescentOptimizerBasev4Template() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Abstract base for object-to-object optimizers.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:83