ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkGradientDescentOptimizerv4.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
76 template<typename TInternalComputationValueType>
77 class ITK_TEMPLATE_EXPORT GradientDescentOptimizerv4Template
78 : public GradientDescentOptimizerBasev4Template<TInternalComputationValueType>
79 {
80 public:
81  ITK_DISALLOW_COPY_AND_ASSIGN(GradientDescentOptimizerv4Template);
82 
88 
91 
93  itkNewMacro(Self);
94 
95 
97  using InternalComputationValueType = TInternalComputationValueType;
98 
101 
104  using IndexRangeType = typename Superclass::IndexRangeType;
105  using ScalesType = typename Superclass::ScalesType;
107  using StopConditionType = typename Superclass::StopConditionType;
108 
112  itkSetMacro(LearningRate, TInternalComputationValueType);
113  itkGetConstReferenceMacro(LearningRate, TInternalComputationValueType);
115 
122  itkSetMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
123  itkGetConstReferenceMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
125 
133  itkSetMacro(DoEstimateLearningRateAtEachIteration, bool);
134  itkGetConstReferenceMacro(DoEstimateLearningRateAtEachIteration, bool);
135  itkBooleanMacro(DoEstimateLearningRateAtEachIteration);
137 
145  itkSetMacro(DoEstimateLearningRateOnce, bool);
146  itkGetConstReferenceMacro(DoEstimateLearningRateOnce, bool);
147  itkBooleanMacro(DoEstimateLearningRateOnce);
149 
159  itkSetMacro(MinimumConvergenceValue, TInternalComputationValueType);
160 
169  itkSetMacro(ConvergenceWindowSize, SizeValueType);
170 
174  itkGetConstReferenceMacro( ConvergenceValue, TInternalComputationValueType);
175 
187  itkSetMacro(ReturnBestParametersAndValue, bool);
188  itkGetConstReferenceMacro(ReturnBestParametersAndValue, bool);
189  itkBooleanMacro(ReturnBestParametersAndValue);
191 
193  void StartOptimization( bool doOnlyInitialization = false ) override;
194 
196  void StopOptimization() override;
197 
199  void ResumeOptimization() override;
200 
202  virtual void EstimateLearningRate();
203 
204 protected:
205 
208  virtual void AdvanceOneStep();
209 
211  void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange ) override;
212 
214  void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange ) override;
215 
218 
220  ~GradientDescentOptimizerv4Template() override = default;
221 
222  void PrintSelf( std::ostream & os, Indent indent ) const override;
223 
224 
225  TInternalComputationValueType m_LearningRate;
226  TInternalComputationValueType m_MinimumConvergenceValue;
227  TInternalComputationValueType m_ConvergenceValue;
228 
232 
233  bool m_ReturnBestParametersAndValue{ false };
234 
241 
242 private:
243 
244 };
245 
248 
249 } // end namespace itk
250 
251 #ifndef ITK_MANUAL_INSTANTIATION
252 #include "itkGradientDescentOptimizerv4.hxx"
253 #endif
254 
255 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType