ITK  4.13.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 
110  itkSetMacro(LearningRate, TInternalComputationValueType);
111  itkGetConstReferenceMacro(LearningRate, TInternalComputationValueType);
113 
120  itkSetMacro(MaximumStepSizeInPhysicalUnits, TInternalComputationValueType);
121  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 
172  itkGetConstReferenceMacro( ConvergenceValue, TInternalComputationValueType);
173 
185  itkSetMacro(ReturnBestParametersAndValue, bool);
186  itkGetConstReferenceMacro(ReturnBestParametersAndValue, bool);
187  itkBooleanMacro(ReturnBestParametersAndValue);
189 
191  virtual void StartOptimization( bool doOnlyInitialization = false ) ITK_OVERRIDE;
192 
194  virtual void StopOptimization(void) ITK_OVERRIDE;
195 
197  virtual void ResumeOptimization() ITK_OVERRIDE;
198 
200  virtual void EstimateLearningRate();
201 
202 protected:
203 
206  virtual void AdvanceOneStep();
207 
209  virtual void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange ) ITK_OVERRIDE;
210 
212  virtual void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange ) ITK_OVERRIDE;
213 
216 
218  virtual ~GradientDescentOptimizerv4Template() ITK_OVERRIDE;
219 
220  virtual void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
221 
222 
223  TInternalComputationValueType m_LearningRate;
224  TInternalComputationValueType m_MinimumConvergenceValue;
225  TInternalComputationValueType m_ConvergenceValue;
226 
228  MeasureType m_CurrentBestValue;
229  ParametersType m_BestParameters;
230 
231  bool m_ReturnBestParametersAndValue;
232 
238  DerivativeType m_PreviousGradient;
239 
240 private:
241 
242  ITK_DISALLOW_COPY_AND_ASSIGN(GradientDescentOptimizerv4Template);
243 };
244 
246 typedef GradientDescentOptimizerv4Template<double> GradientDescentOptimizerv4;
247 
248 } // end namespace itk
249 
250 #ifndef ITK_MANUAL_INSTANTIATION
251 #include "itkGradientDescentOptimizerv4.hxx"
252 #endif
253 
254 #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