ITK  6.0.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  * 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 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);
90 
92  itkOverrideGetNameOfClassMacro(GradientDescentOptimizerv4Template);
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);
124  itkSetMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
125  itkGetConstReferenceMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
135  itkSetMacro(DoEstimateLearningRateAtEachIteration, bool);
136  itkGetConstReferenceMacro(DoEstimateLearningRateAtEachIteration, bool);
137  itkBooleanMacro(DoEstimateLearningRateAtEachIteration);
147  itkSetMacro(DoEstimateLearningRateOnce, bool);
148  itkGetConstReferenceMacro(DoEstimateLearningRateOnce, bool);
149  itkBooleanMacro(DoEstimateLearningRateOnce);
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);
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 
239  MeasureType m_CurrentBestValue{};
240  ParametersType m_BestParameters{};
241 
242  bool m_ReturnBestParametersAndValue{ false };
243 
249  DerivativeType m_PreviousGradient{};
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::GradientDescentOptimizerv4Template
Gradient descent optimizer.
Definition: itkGradientDescentOptimizerv4.h:78
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GradientDescentOptimizerBasev4Template::IndexRangeType
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Definition: itkGradientDescentOptimizerBasev4.h:142
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkGradientDescentOptimizerBasev4.h
itk::GradientDescentOptimizerBasev4Template::InternalComputationValueType
TInternalComputationValueType InternalComputationValueType
Definition: itkGradientDescentOptimizerBasev4.h:80
itk::GradientDescentOptimizerBasev4Template
Definition: itkGradientDescentOptimizerBasev4.h:40
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86