ITK  5.3.0
Insight Toolkit
itkGradientDescentOptimizerv4.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 itkGradientDescentOptimizerv4_h
19 #define itkGradientDescentOptimizerv4_h
20 
22 
23 namespace itk
24 {
77 template <typename TInternalComputationValueType>
78 class ITK_TEMPLATE_EXPORT GradientDescentOptimizerv4Template
79  : public GradientDescentOptimizerBasev4Template<TInternalComputationValueType>
80 {
81 public:
82  ITK_DISALLOW_COPY_AND_MOVE(GradientDescentOptimizerv4Template);
84 
90 
93 
95  itkNewMacro(Self);
96 
97 
99  using InternalComputationValueType = TInternalComputationValueType;
100 
102  using typename Superclass::DerivativeType;
103 
105  using typename Superclass::MeasureType;
106  using typename Superclass::IndexRangeType;
107  using typename Superclass::ScalesType;
108  using typename Superclass::ParametersType;
109 
114  itkSetMacro(LearningRate, TInternalComputationValueType);
115  itkGetConstReferenceMacro(LearningRate, TInternalComputationValueType);
117 
124  itkSetMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
125  itkGetConstReferenceMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
127 
135  itkSetMacro(DoEstimateLearningRateAtEachIteration, bool);
136  itkGetConstReferenceMacro(DoEstimateLearningRateAtEachIteration, bool);
137  itkBooleanMacro(DoEstimateLearningRateAtEachIteration);
139 
147  itkSetMacro(DoEstimateLearningRateOnce, bool);
148  itkGetConstReferenceMacro(DoEstimateLearningRateOnce, bool);
149  itkBooleanMacro(DoEstimateLearningRateOnce);
151 
161  itkSetMacro(MinimumConvergenceValue, TInternalComputationValueType);
162 
171  itkSetMacro(ConvergenceWindowSize, SizeValueType);
172 
176  itkGetConstReferenceMacro(ConvergenceValue, TInternalComputationValueType);
177 
189  itkSetMacro(ReturnBestParametersAndValue, bool);
190  itkGetConstReferenceMacro(ReturnBestParametersAndValue, bool);
191  itkBooleanMacro(ReturnBestParametersAndValue);
193 
195  void
196  StartOptimization(bool doOnlyInitialization = false) override;
197 
199  void
200  StopOptimization() override;
201 
203  void
204  ResumeOptimization() override;
205 
207  virtual void
208  EstimateLearningRate();
209 
210 protected:
213  virtual void
214  AdvanceOneStep();
215 
217  void
218  ModifyGradientByScalesOverSubRange(const IndexRangeType & subrange) override;
219 
221  void
222  ModifyGradientByLearningRateOverSubRange(const IndexRangeType & subrange) override;
223 
226 
228  ~GradientDescentOptimizerv4Template() override = default;
229 
230  void
231  PrintSelf(std::ostream & os, Indent indent) const override;
232 
233 
234  TInternalComputationValueType m_LearningRate;
235  TInternalComputationValueType m_MinimumConvergenceValue;
236  TInternalComputationValueType m_ConvergenceValue;
237 
241 
242  bool m_ReturnBestParametersAndValue{ false };
243 
250 
251 private:
252 };
253 
256 
257 } // end namespace itk
258 
259 #ifndef ITK_MANUAL_INSTANTIATION
260 # include "itkGradientDescentOptimizerv4.hxx"
261 #endif
262 
263 #endif
itk::OptimizerParameters< double >
itk::GradientDescentOptimizerv4Template::m_CurrentBestValue
MeasureType m_CurrentBestValue
Definition: itkGradientDescentOptimizerv4.h:239
itk::GradientDescentOptimizerv4Template
Gradient descent optimizer.
Definition: itkGradientDescentOptimizerv4.h:78
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GradientDescentOptimizerBasev4Template< double >::IndexRangeType
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Definition: itkGradientDescentOptimizerBasev4.h:169
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::GradientDescentOptimizerv4Template::m_MinimumConvergenceValue
TInternalComputationValueType m_MinimumConvergenceValue
Definition: itkGradientDescentOptimizerv4.h:235
itkGradientDescentOptimizerBasev4.h
itk::GradientDescentOptimizerBasev4Template< double >::InternalComputationValueType
double InternalComputationValueType
Definition: itkGradientDescentOptimizerBasev4.h:80
itk::ObjectToObjectOptimizerBaseTemplate< double >::DerivativeType
typename MetricType::DerivativeType DerivativeType
Definition: itkObjectToObjectOptimizerBase.h:139
itk::GradientDescentOptimizerv4Template::m_LearningRate
TInternalComputationValueType m_LearningRate
Definition: itkGradientDescentOptimizerv4.h:234
itk::GradientDescentOptimizerBasev4Template
Definition: itkGradientDescentOptimizerBasev4.h:40
itk::GradientDescentOptimizerv4Template::m_ConvergenceValue
TInternalComputationValueType m_ConvergenceValue
Definition: itkGradientDescentOptimizerv4.h:236
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::GradientDescentOptimizerv4Template::m_BestParameters
ParametersType m_BestParameters
Definition: itkGradientDescentOptimizerv4.h:240
itk::GradientDescentOptimizerv4Template::m_PreviousGradient
DerivativeType m_PreviousGradient
Definition: itkGradientDescentOptimizerv4.h:249
itk::ObjectToObjectOptimizerBaseTemplate< double >::MeasureType
typename MetricType::MeasureType MeasureType
Definition: itkObjectToObjectOptimizerBase.h:145
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83