ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkRegularStepGradientDescentOptimizerv4.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 itkRegularStepGradientDescentOptimizerv4_h
19 #define itkRegularStepGradientDescentOptimizerv4_h
20 
23 
24 namespace itk
25 {
45 template<typename TInternalComputationValueType>
46 class ITK_TEMPLATE_EXPORT RegularStepGradientDescentOptimizerv4
47 : public GradientDescentOptimizerv4Template<TInternalComputationValueType>
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_ASSIGN(RegularStepGradientDescentOptimizerv4);
51 
57 
60 
62  itkNewMacro(Self);
63 
64 
66  using InternalComputationValueType = TInternalComputationValueType;
67 
69  using DerivativeType = typename Superclass::DerivativeType;
70 
73  using IndexRangeType = typename Superclass::IndexRangeType;
74  using ScalesType = typename Superclass::ScalesType;
75  using ParametersType = typename Superclass::ParametersType;
76  using StopConditionType = typename Superclass::StopConditionType;
77 
80 
90  itkSetMacro(MinimumStepLength, TInternalComputationValueType);
91  itkGetConstReferenceMacro(MinimumStepLength, TInternalComputationValueType);
93 
95  itkSetMacro(RelaxationFactor, TInternalComputationValueType);
96  itkGetConstReferenceMacro(RelaxationFactor, TInternalComputationValueType);
98 
100  itkSetMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
101  itkGetConstReferenceMacro(GradientMagnitudeTolerance, TInternalComputationValueType);
103 
105  itkSetMacro(CurrentLearningRateRelaxation, MeasureType);
106  itkGetConstReferenceMacro(CurrentLearningRateRelaxation, MeasureType);
108 
110  void StartOptimization( bool doOnlyInitialization = false ) override;
111 
113  void EstimateLearningRate() override;
114 
116  double GetCurrentStepLength() const;
117 
118 protected:
119 
122  void AdvanceOneStep() override;
123 
125  void ModifyGradientByScalesOverSubRange( const IndexRangeType& subrange ) override;
126  void ModifyGradientByLearningRateOverSubRange( const IndexRangeType& subrange ) override;
128 
129 
132 
134  ~RegularStepGradientDescentOptimizerv4() override = default;
135 
136  void PrintSelf( std::ostream & os, Indent indent ) const override;
137 
138 
139 private:
140  TInternalComputationValueType m_RelaxationFactor;
141 
142  TInternalComputationValueType m_MinimumStepLength;
143 
144  TInternalComputationValueType m_GradientMagnitudeTolerance;
145 
147 };
148 
149 } // end namespace itk
150 
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "itkRegularStepGradientDescentOptimizerv4.hxx"
153 #endif
154 
155 #endif
Light weight base class for most itk classes.
Perform more precise accumulation of floating point numbers.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType