go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkStochasticGradientDescentOptimizer.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 __itkStochasticGradientDescentOptimizer_h
19#define __itkStochasticGradientDescentOptimizer_h
20
22#include "itkPlatformMultiThreader.h"
23
24namespace itk
25{
55{
56public:
61 typedef SmartPointer<const Self> ConstPointer;
62
64 itkNewMacro( Self );
65
68
77
81 typedef enum {
89
91 virtual void AdvanceOneStep( void );
92
94 void StartOptimization( void ) override;
95
98 virtual void ResumeOptimization( void );
99
101 virtual void MetricErrorResponse( ExceptionObject & err );
102
105 virtual void StopOptimization( void );
106
108 itkSetMacro( LearningRate, double );
109
111 itkGetConstReferenceMacro( LearningRate, double );
112
114 itkSetMacro( NumberOfIterations, unsigned long );
115
117 itkGetConstMacro( LBFGSMemory, unsigned int );
118
120 itkGetConstReferenceMacro( NumberOfIterations, unsigned long );
121
123 itkGetConstReferenceMacro( NumberOfInnerIterations, unsigned long );
124
126 itkGetConstMacro( CurrentIteration, unsigned int );
127
129 itkGetConstMacro( CurrentInnerIteration, unsigned int );
130
132 itkGetConstReferenceMacro( Value, double );
133
135 itkGetConstReferenceMacro( StopCondition, StopConditionType );
136
138 itkGetConstReferenceMacro( Gradient, DerivativeType );
139
141 itkGetConstReferenceMacro( SearchDir, DerivativeType );
142
144 itkSetMacro( PreviousPosition, ParametersType );
145
147 itkGetConstReferenceMacro( PreviousPosition, ParametersType );
148
150 itkSetMacro( PreviousGradient, DerivativeType );
151
153 itkGetConstReferenceMacro( PreviousGradient, DerivativeType );
154
156 void SetNumberOfWorkUnits( ThreadIdType numberOfThreads )
157 {
158 this->m_Threader->SetNumberOfWorkUnits( numberOfThreads );
159 }
160 //itkGetConstReferenceMacro( NumberOfThreads, ThreadIdType );
161 itkSetMacro( UseMultiThread, bool );
162
163 itkSetMacro( UseOpenMP, bool );
164 itkSetMacro( UseEigen, bool );
165
166protected:
169 void PrintSelf( std::ostream& os, Indent indent ) const override;
170
172 typedef itk::PlatformMultiThreader ThreaderType;
173 typedef ThreaderType::WorkUnitInfo ThreadInfoType;
174
175 // made protected so subclass can access
176 double m_Value;
187 ThreaderType::Pointer m_Threader;
188
189 bool m_Stop;
190 unsigned long m_NumberOfIterations;
192 unsigned long m_CurrentIteration;
194 unsigned long m_LBFGSMemory;
195
196private:
197 StochasticGradientDescentOptimizer( const Self& ); //purposely not implemented
198 void operator=( const Self& ); //purposely not implemented
199
200 // multi-threaded AdvanceOneStep:
203 {
206 };
207
210
212 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AdvanceOneStepThreaderCallback( void * arg );
213
215 inline void ThreadedAdvanceOneStep( ThreadIdType threadId, ParametersType & newPosition );
216
217};
218
219} // end namespace itk
220
221
222#endif
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AdvanceOneStepThreaderCallback(void *arg)
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void MetricErrorResponse(ExceptionObject &err)
Superclass::ScaledCostFunctionPointer ScaledCostFunctionPointer
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)


Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo