go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxPreconditionedStochasticGradientDescent.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 elxPreconditionedStochasticGradientDescent_h
19#define elxPreconditionedStochasticGradientDescent_h
20
21#include "elxIncludes.h" // include first to avoid MSVS warning
23#include "itkComputeDisplacementDistribution.h" // For fast step size estimation
24
25
27#include "elxProgressCommand.h"
29#include "itkMersenneTwisterRandomVariateGenerator.h"
32
33
34namespace elastix
35{
177template <class TElastix>
180 , public OptimizerBase<TElastix>
181{
182public:
184
189 using Pointer = itk::SmartPointer<Self>;
190 using ConstPointer = itk::SmartPointer<const Self>;
191
193 itkNewMacro(Self);
194
196 itkTypeMacro(PreconditionedStochasticGradientDescent, VoxelWiseASGDOptimizer);
197
202 elxClassNameMacro("PreconditionedStochasticGradientDescent");
203
205 using Superclass1::CostFunctionType;
206 using Superclass1::CostFunctionPointer;
208
210 using typename Superclass2::ElastixType;
211 using typename Superclass2::RegistrationType;
213 using SizeValueType = itk::SizeValueType;
214
216 using typename Superclass1::ParametersType;
217
221 void
223
224 void
226
227 void
229
230 void
232
233 void
235
239 void
241
243 void
244 AdvanceOneStep() override;
245
250 void
252
254 void
255 MetricErrorResponse(itk::ExceptionObject & err) override;
256
266 itkSetMacro(AutomaticParameterEstimation, bool);
267 itkGetConstMacro(AutomaticParameterEstimation, bool);
268
270 itkSetMacro(MaximumStepLength, double);
271 itkGetConstReferenceMacro(MaximumStepLength, double);
272
274 itkSetClampMacro(RegularizationKappa, double, 0.0, 1.0);
275 itkGetConstReferenceMacro(RegularizationKappa, double);
276
278 itkSetMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
279 itkGetConstReferenceMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
280
281protected:
284
286 using FixedImageType = typename RegistrationType::FixedImageType;
287 using MovingImageType = typename RegistrationType::MovingImageType;
288
289 using FixedImageRegionType = typename FixedImageType::RegionType;
290 using FixedImageIndexType = typename FixedImageType::IndexType;
291 using FixedImagePointType = typename FixedImageType::PointType;
292 using itkRegistrationType = typename RegistrationType::ITKBaseType;
293 using TransformType = typename itkRegistrationType::TransformType;
294 using JacobianType = typename TransformType::JacobianType;
295 using JacobianValueType = typename JacobianType::ValueType;
296 using typename Superclass2::SettingsType;
297 using typename Superclass2::SettingsVectorType;
298 using OutputImageType = typename ElastixType::FixedImageType;
299
303
305
318 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
319
321 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
322 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
323
326 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
327 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
328 using CoordinateRepresentationType = typename TransformType::ScalarType;
329
334
338
341
348
351
354
360
365 virtual void
367
375 virtual void
376 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
377
381 virtual void
382 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
383
387 virtual void
388 AddRandomPerturbation(ParametersType & parameters, double sigma);
389
390private:
392
396
402
406
410};
411
412} // end namespace elastix
413
414#ifndef ITK_MANUAL_INSTANTIATION
415# include "elxPreconditionedStochasticGradientDescent.hxx"
416#endif
417
418#endif // end #ifndef elxPreconditionedStochasticGradientDescent_h
This class is the elastix base class for all Optimizers.
typename ElastixType::RegistrationBaseType RegistrationType
typename std::vector< SettingsType > SettingsVectorType
typename ITKBaseType::ParametersType ParametersType
typename ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
typename PreconditionerEstimationType::Pointer PreconditionerEstimationPointer
typename AdvancedBSplineDeformableTransformType::Pointer BSplineTransformBasePointer
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
ITK_DISALLOW_COPY_AND_MOVE(PreconditionedStochasticGradientDescent)
elxClassNameMacro("PreconditionedStochasticGradientDescent")
typename std::vector< SettingsType > SettingsVectorType
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
void MetricErrorResponse(itk::ExceptionObject &err) override
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Base class for deformable transform using a B-spline representation.
Transform maps points, vectors and covariant vectors from an input space to an output space.
std::vector< unsigned long > NonZeroJacobianIndicesType
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
This is a helper class for the automatic estimation of a preconditioner for the FPSGD optimizer....
Samples image voxels on a regular grid.
Samples an image by randomly composing a set of physical coordinates.
This class is a base class for any image sampler that randomly picks samples.
Samples randomly some voxels of an image.
This class is a base class for any image sampler.
This class implements a gradient descent optimizer with adaptive gain.
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo