go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkStochasticVarianceReducedGradientDescentOptimizer.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
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 itkStochasticVarianceReducedGradientDescentOptimizer_h
19#define itkStochasticVarianceReducedGradientDescentOptimizer_h
20
22#include "itkPlatformMultiThreader.h"
23
24namespace itk
25{
53{
54public:
56
60 using Pointer = SmartPointer<Self>;
61 using ConstPointer = SmartPointer<const Self>;
62
64 itkNewMacro(Self);
65
68
70 using Superclass::MeasureType;
71 using Superclass::ParametersType;
72 using Superclass::DerivativeType;
73 using Superclass::CostFunctionType;
77
82 {
89 };
90
92 virtual void
94
96 void
98
101 virtual void
103
105 virtual void
106 MetricErrorResponse(ExceptionObject & err);
107
110 virtual void
112
114 itkSetMacro(LearningRate, double);
115
117 itkGetConstReferenceMacro(LearningRate, double);
118
120 itkSetMacro(NumberOfIterations, unsigned long);
121
123 itkGetConstMacro(LBFGSMemory, unsigned int);
124
126 itkGetConstReferenceMacro(NumberOfIterations, unsigned long);
127
129 itkGetConstReferenceMacro(NumberOfInnerIterations, unsigned long);
130
132 itkGetConstMacro(CurrentIteration, unsigned int);
133
135 itkGetConstMacro(CurrentInnerIteration, unsigned int);
136
138 itkGetConstReferenceMacro(Value, double);
139
141 itkGetConstReferenceMacro(StopCondition, StopConditionType);
142
144 itkGetConstReferenceMacro(Gradient, DerivativeType);
145
147 itkGetConstReferenceMacro(SearchDir, DerivativeType);
148
150 itkSetMacro(PreviousPosition, ParametersType);
151
153 itkGetConstReferenceMacro(PreviousPosition, ParametersType);
154
156 itkSetMacro(PreviousGradient, DerivativeType);
157
159 itkGetConstReferenceMacro(PreviousGradient, DerivativeType);
160
162 void
163 SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
164 {
165 this->m_Threader->SetNumberOfWorkUnits(numberOfThreads);
166 }
167 // itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
168 itkSetMacro(UseMultiThread, bool);
169
170 itkSetMacro(UseOpenMP, bool);
171 itkSetMacro(UseEigen, bool);
172
173protected:
176 void
177 PrintSelf(std::ostream & os, Indent indent) const override;
178
180 using ThreaderType = itk::PlatformMultiThreader;
181 using ThreadInfoType = ThreaderType::WorkUnitInfo;
182
183 // made protected so subclass can access
184 double m_Value{ 0.0 };
185 DerivativeType m_Gradient;
186 ParametersType m_SearchDir;
187 ParametersType m_PreviousSearchDir;
188 // ParametersType m_PrePreviousSearchDir;
189 ParametersType m_MeanSearchDir;
190 double m_LearningRate{ 1.0 };
192 DerivativeType m_PreviousGradient;
193 // DerivativeType m_PrePreviousGradient;
194 ParametersType m_PreviousPosition;
195 ThreaderType::Pointer m_Threader{ ThreaderType::New() };
196
197 bool m_Stop{ false };
198 unsigned long m_NumberOfIterations{ 100 };
200 unsigned long m_CurrentIteration{ 0 };
202 unsigned long m_LBFGSMemory{ 0 };
203
204private:
205 // multi-threaded AdvanceOneStep:
206 bool m_UseMultiThread{ false };
208 {
209 ParametersType * t_NewPosition;
211 };
212
213 bool m_UseOpenMP{ false };
214 bool m_UseEigen{ false };
215
217 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
219
221 inline void
222 ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType & newPosition);
223};
224
225} // end namespace itk
226
227
228#endif
A cost function that applies a scaling to another cost function.
virtual void MetricErrorResponse(ExceptionObject &err)
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AdvanceOneStepThreaderCallback(void *arg)
ITK_DISALLOW_COPY_AND_MOVE(StochasticVarianceReducedGradientDescentOptimizer)
void PrintSelf(std::ostream &os, Indent indent) const override


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo