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 "itkMultiThreaderBase.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
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 itkSetMacro(UseEigen, bool);
170
171protected:
174 void
175 PrintSelf(std::ostream & os, Indent indent) const override;
176
178 using ThreadInfoType = MultiThreaderBase::WorkUnitInfo;
179
180 // made protected so subclass can access
181 double m_Value{ 0.0 };
182 DerivativeType m_Gradient{};
183 ParametersType m_SearchDir{};
184 ParametersType m_PreviousSearchDir{};
185 // ParametersType m_PrePreviousSearchDir;
186 ParametersType m_MeanSearchDir{};
187 double m_LearningRate{ 1.0 };
189 DerivativeType m_PreviousGradient{};
190 // DerivativeType m_PrePreviousGradient;
191 ParametersType m_PreviousPosition{};
192 MultiThreaderBase::Pointer m_Threader{ MultiThreaderBase::New() };
193
194 bool m_Stop{ false };
195 unsigned long m_NumberOfIterations{ 100 };
197 unsigned long m_CurrentIteration{ 0 };
198 unsigned long m_CurrentInnerIteration{};
199 unsigned long m_LBFGSMemory{ 0 };
200
201private:
202 // multi-threaded AdvanceOneStep:
203 bool m_UseMultiThread{ false };
205 {
206 ParametersType * t_NewPosition;
208 };
209
210 bool m_UseEigen{ false };
211
213 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
215
217 inline void
218 ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType & newPosition);
219};
220
221} // end namespace itk
222
223
224#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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo