ITK  5.2.0
Insight Toolkit
itkRegularStepGradientDescentOptimizerv4.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  * http://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 itkRegularStepGradientDescentOptimizerv4_h
19 #define itkRegularStepGradientDescentOptimizerv4_h
20 
23 
24 namespace itk
25 {
46 template <typename TInternalComputationValueType>
47 class ITK_TEMPLATE_EXPORT RegularStepGradientDescentOptimizerv4
48  : public GradientDescentOptimizerv4Template<TInternalComputationValueType>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(RegularStepGradientDescentOptimizerv4);
52 
58 
61 
63  itkNewMacro(Self);
64 
65 
67  using InternalComputationValueType = TInternalComputationValueType;
68 
70  using DerivativeType = typename Superclass::DerivativeType;
71 
74  using IndexRangeType = typename Superclass::IndexRangeType;
75  using ScalesType = typename Superclass::ScalesType;
76  using ParametersType = typename Superclass::ParametersType;
77 
80 
90  itkSetMacro(MinimumStepLength, TInternalComputationValueType);
91  itkGetConstReferenceMacro(MinimumStepLength, TInternalComputationValueType);
93 
95  itkSetMacro(RelaxationFactor, TInternalComputationValueType);
96  itkGetConstReferenceMacro(RelaxationFactor, TInternalComputationValueType);
98 
100  itkSetMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
101  itkGetConstReferenceMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
103 
105  itkSetMacro(CurrentLearningRateRelaxation, MeasureType);
106  itkGetConstReferenceMacro(CurrentLearningRateRelaxation, MeasureType);
108 
110  void
111  StartOptimization(bool doOnlyInitialization = false) override;
112 
114  void
115  EstimateLearningRate() override;
116 
118  double
119  GetCurrentStepLength() const;
120 
121 protected:
124  void
125  AdvanceOneStep() override;
126 
128  void
129  ModifyGradientByScalesOverSubRange(const IndexRangeType & subrange) override;
130  void
131  ModifyGradientByLearningRateOverSubRange(const IndexRangeType & subrange) override;
133 
134 
137 
139  ~RegularStepGradientDescentOptimizerv4() override = default;
140 
141  void
142  PrintSelf(std::ostream & os, Indent indent) const override;
143 
144 
145 private:
146  TInternalComputationValueType m_RelaxationFactor;
147 
148  TInternalComputationValueType m_MinimumStepLength;
149 
150  TInternalComputationValueType m_GradientMagnitudeTolerance;
151 
153 };
154 
155 } // end namespace itk
156 
157 #ifndef ITK_MANUAL_INSTANTIATION
158 # include "itkRegularStepGradientDescentOptimizerv4.hxx"
159 #endif
160 
161 #endif
itk::CompensatedSummation
Perform more precise accumulation of floating point numbers.
Definition: itkCompensatedSummation.h:66
itk::RegularStepGradientDescentOptimizerv4::m_RelaxationFactor
TInternalComputationValueType m_RelaxationFactor
Definition: itkRegularStepGradientDescentOptimizerv4.h:146
itk::GradientDescentOptimizerv4Template
Gradient descent optimizer.
Definition: itkGradientDescentOptimizerv4.h:78
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkCompensatedSummation.h
itk::GradientDescentOptimizerBasev4Template::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkGradientDescentOptimizerBasev4.h:94
itk::RegularStepGradientDescentOptimizerv4::m_MinimumStepLength
TInternalComputationValueType m_MinimumStepLength
Definition: itkRegularStepGradientDescentOptimizerv4.h:148
itk::GradientDescentOptimizerBasev4Template::IndexRangeType
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Definition: itkGradientDescentOptimizerBasev4.h:169
itk::RegularStepGradientDescentOptimizerv4
Regular Step Gradient descent optimizer.
Definition: itkRegularStepGradientDescentOptimizerv4.h:47
itk::RegularStepGradientDescentOptimizerv4::m_CurrentLearningRateRelaxation
MeasureType m_CurrentLearningRateRelaxation
Definition: itkRegularStepGradientDescentOptimizerv4.h:152
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkGradientDescentOptimizerv4.h
itk::GradientDescentOptimizerBasev4Template::InternalComputationValueType
TInternalComputationValueType InternalComputationValueType
Definition: itkGradientDescentOptimizerBasev4.h:80
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::RegularStepGradientDescentOptimizerv4::m_GradientMagnitudeTolerance
TInternalComputationValueType m_GradientMagnitudeTolerance
Definition: itkRegularStepGradientDescentOptimizerv4.h:150
itk::GradientDescentOptimizerBasev4Template::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkGradientDescentOptimizerBasev4.h:87
itk::GradientDescentOptimizerBasev4Template::ScalesType
typename Superclass::ScalesType ScalesType
Definition: itkGradientDescentOptimizerBasev4.h:92
itk::GradientDescentOptimizerv4Template::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkGradientDescentOptimizerv4.h:105
itk::GradientDescentOptimizerBasev4Template::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkGradientDescentOptimizerBasev4.h:90