ITK  4.11.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:
86 
89 
91  itkNewMacro(Self);
92 
93 
95  typedef TInternalComputationValueType InternalComputationValueType;
96 
98  typedef typename Superclass::DerivativeType DerivativeType;
99 
102  typedef typename Superclass::IndexRangeType IndexRangeType;
103  typedef typename Superclass::ScalesType ScalesType;
104  typedef typename Superclass::ParametersType ParametersType;
106 
108  itkSetMacro(LearningRate, TInternalComputationValueType);
109 
111  itkGetConstReferenceMacro(LearningRate, TInternalComputationValueType);
112 
119  itkSetMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
120 
122  itkGetConstReferenceMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
123 
131  itkSetMacro(DoEstimateLearningRateAtEachIteration, bool);
132  itkGetConstReferenceMacro(DoEstimateLearningRateAtEachIteration, bool);
133  itkBooleanMacro(DoEstimateLearningRateAtEachIteration);
135 
143  itkSetMacro(DoEstimateLearningRateOnce, bool);
144  itkGetConstReferenceMacro(DoEstimateLearningRateOnce, bool);
145  itkBooleanMacro(DoEstimateLearningRateOnce);
147 
157  itkSetMacro(MinimumConvergenceValue, TInternalComputationValueType);
158 
167  itkSetMacro(ConvergenceWindowSize, SizeValueType);
168 
170  itkGetConstReferenceMacro( ConvergenceValue, TInternalComputationValueType);
171 
183  itkSetMacro(ReturnBestParametersAndValue, bool);
184  itkGetConstReferenceMacro(ReturnBestParametersAndValue, bool);
185  itkBooleanMacro(ReturnBestParametersAndValue);
187 
189  virtual void StartOptimization( bool doOnlyInitialization = false ) ITK_OVERRIDE;
190 
191  virtual void StopOptimization(void) ITK_OVERRIDE;
192 
193  virtual void ResumeOptimization() ITK_OVERRIDE;
194 
196  virtual void EstimateLearningRate();
197 
198 protected:
199 
202  virtual void AdvanceOneStep();
203 
205  virtual void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange ) ITK_OVERRIDE;
206  virtual void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange ) ITK_OVERRIDE;
208 
212  TInternalComputationValueType m_LearningRate;
213 
216 
219 
220  virtual void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
221 
227  TInternalComputationValueType m_MinimumConvergenceValue;
228 
230  /* WindowConvergenceMonitoringFunction always returns output convergence value in 'TInternalComputationValueType' precision */
231  TInternalComputationValueType m_ConvergenceValue;
232 
234  MeasureType m_CurrentBestValue;
235  ParametersType m_BestParameters;
236 
238  bool m_ReturnBestParametersAndValue;
239 
245  DerivativeType m_PreviousGradient;
246 
247 private:
248 
249  ITK_DISALLOW_COPY_AND_ASSIGN(GradientDescentOptimizerv4Template);
250 };
251 
253 typedef GradientDescentOptimizerv4Template<double> GradientDescentOptimizerv4;
254 
255 } // end namespace itk
256 
257 #ifndef ITK_MANUAL_INSTANTIATION
258 #include "itkGradientDescentOptimizerv4.hxx"
259 #endif
260 
261 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
GradientDescentOptimizerBasev4Template< TInternalComputationValueType > Superclass
TInternalComputationValueType InternalComputationValueType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType