ITK  6.0.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  * 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 itkRegularStepGradientDescentOptimizerv4_h
19 #define itkRegularStepGradientDescentOptimizerv4_h
20 
23 
24 namespace itk
25 {
46 template <typename TInternalComputationValueType = double>
47 class ITK_TEMPLATE_EXPORT RegularStepGradientDescentOptimizerv4
48  : public GradientDescentOptimizerv4Template<TInternalComputationValueType>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(RegularStepGradientDescentOptimizerv4);
52 
58 
60  itkOverrideGetNameOfClassMacro(RegularStepGradientDescentOptimizerv4);
61 
63  itkNewMacro(Self);
64 
65 
67  using InternalComputationValueType = TInternalComputationValueType;
68 
70  using typename Superclass::DerivativeType;
71 
73  using typename Superclass::MeasureType;
74  using typename Superclass::IndexRangeType;
75  using typename Superclass::ScalesType;
76  using typename Superclass::ParametersType;
77 
80 
90  itkSetMacro(MinimumStepLength, TInternalComputationValueType);
91  itkGetConstReferenceMacro(MinimumStepLength, TInternalComputationValueType);
95  itkSetMacro(RelaxationFactor, TInternalComputationValueType);
96  itkGetConstReferenceMacro(RelaxationFactor, TInternalComputationValueType);
100  itkSetMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
101  itkGetConstReferenceMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
105  itkSetMacro(CurrentLearningRateRelaxation, MeasureType);
106  itkGetConstReferenceMacro(CurrentLearningRateRelaxation, MeasureType);
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;
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 
152  MeasureType m_CurrentLearningRateRelaxation{};
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::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::IndexRangeType
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Definition: itkGradientDescentOptimizerBasev4.h:142
itk::RegularStepGradientDescentOptimizerv4
Regular Step Gradient descent optimizer.
Definition: itkRegularStepGradientDescentOptimizerv4.h:47
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
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: itkAnatomicalOrientation.h:29
itk::ObjectToObjectOptimizerBaseTemplate::MeasureType
typename MetricType::MeasureType MeasureType
Definition: itkObjectToObjectOptimizerBase.h:145