go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxAdaGrad.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 elxAdaGrad_h
19#define elxAdaGrad_h
20
21#include "elxIncludes.h" // include first to avoid MSVS warning
23
25#include "itkComputeDisplacementDistribution.h" // For fast step size estimation
26
27#include "elxProgressCommand.h"
29#include "itkMersenneTwisterRandomVariateGenerator.h"
32
33
34namespace elastix
35{
189template <class TElastix>
190class ITK_TEMPLATE_EXPORT AdaGrad
192 , public OptimizerBase<TElastix>
193{
194public:
196
198 using Self = AdaGrad;
201 using Pointer = itk::SmartPointer<Self>;
202 using ConstPointer = itk::SmartPointer<const Self>;
203
205 itkNewMacro(Self);
206
208 itkTypeMacro(AdaGrad, VoxelWiseASGDOptimizer);
209
215
217 using Superclass1::CostFunctionType;
218 using Superclass1::CostFunctionPointer;
220
222 using typename Superclass2::ElastixType;
223 using typename Superclass2::RegistrationType;
225 using SizeValueType = itk::SizeValueType;
226
228 using typename Superclass1::ParametersType;
229
233 void
235
236 void
238
239 void
241
242 void
244
245 void
247
251 void
253
255 void
256 AdvanceOneStep() override;
257
262 void
264
266 void
267 MetricErrorResponse(itk::ExceptionObject & err) override;
268
278 itkSetMacro(AutomaticParameterEstimation, bool);
279 itkGetConstMacro(AutomaticParameterEstimation, bool);
280
282 itkSetMacro(MaximumStepLength, double);
283 itkGetConstReferenceMacro(MaximumStepLength, double);
284
286 itkSetClampMacro(RegularizationKappa, double, 0.0, 1.0);
287 itkGetConstReferenceMacro(RegularizationKappa, double);
288
290 itkSetMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
291 itkGetConstReferenceMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
292
293protected:
295 ~AdaGrad() override = default;
296
298 using FixedImageType = typename RegistrationType::FixedImageType;
299 using MovingImageType = typename RegistrationType::MovingImageType;
300
301 using FixedImageRegionType = typename FixedImageType::RegionType;
302 using FixedImageIndexType = typename FixedImageType::IndexType;
303 using FixedImagePointType = typename FixedImageType::PointType;
304 using itkRegistrationType = typename RegistrationType::ITKBaseType;
305 using TransformType = typename itkRegistrationType::TransformType;
306 using JacobianType = typename TransformType::JacobianType;
307 using JacobianValueType = typename JacobianType::ValueType;
308 struct SettingsType
309 {
310 double a, A, alpha, fmax, fmin, omega;
311 };
312 using SettingsVectorType = typename std::vector<SettingsType>;
313 using OutputImageType = typename ElastixType::FixedImageType;
314
318
320
321
334 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
335
337 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
338 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
341
344 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
345 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
346 using CoordinateRepresentationType = typename TransformType::ScalarType;
347
352
356
359
366
369
372
378
380 virtual void
382
387 virtual void
389
397 virtual void
398 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
399
403 virtual void
404 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
405
409 virtual void
410 AddRandomPerturbation(ParametersType & parameters, double sigma);
411
412private:
414
418
424
428
432};
433
434} // end namespace elastix
435
436#ifndef ITK_MANUAL_INSTANTIATION
437# include "elxAdaGrad.hxx"
438#endif
439
440#endif // end #ifndef elxAdaGrad_h
A gradient descent optimizer with an adaptive gain.
Definition: elxAdaGrad.h:193
double m_RegularizationKappa
Definition: elxAdaGrad.h:376
virtual void AutomaticPreconditionerEstimation()
typename std::vector< SettingsType > SettingsVectorType
Definition: elxAdaGrad.h:312
itk::SmartPointer< Self > Pointer
Definition: elxAdaGrad.h:201
typename AdvancedTransformType::Pointer AdvancedTransformPointer
Definition: elxAdaGrad.h:350
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
SizeValueType m_MaxBandCovSize
Definition: elxAdaGrad.h:426
typename ProgressCommand::Pointer ProgressCommandPointer
Definition: elxAdaGrad.h:340
bool m_AutomaticParameterEstimationDone
Definition: elxAdaGrad.h:423
typename ImageRandomSamplerType::Pointer ImageRandomSamplerPointer
Definition: elxAdaGrad.h:330
void MetricErrorResponse(itk::ExceptionObject &err) override
SizeValueType m_NumberOfSamplesForPrecondition
Definition: elxAdaGrad.h:364
typename JacobianType::ValueType JacobianValueType
Definition: elxAdaGrad.h:307
elxClassNameMacro("AdaGrad")
double m_GlobalStepSize
Definition: elxAdaGrad.h:375
AdvancedTransformPointer m_AdvancedTransform
Definition: elxAdaGrad.h:368
typename ImageGridSamplerType::Pointer ImageGridSamplerPointer
Definition: elxAdaGrad.h:332
void AfterEachIteration() override
double m_SigmoidScaleFactor
Definition: elxAdaGrad.h:373
typename RandomGeneratorType::Pointer RandomGeneratorPointer
Definition: elxAdaGrad.h:338
bool m_AutomaticParameterEstimation
Definition: elxAdaGrad.h:415
SizeValueType m_NumberOfSamplesForNoiseCompensationFactor
Definition: elxAdaGrad.h:363
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition: elxAdaGrad.h:351
itk::SmartPointer< const Self > ConstPointer
Definition: elxAdaGrad.h:202
typename TransformType::ScalarType CoordinateRepresentationType
Definition: elxAdaGrad.h:346
typename RegistrationType::ITKBaseType itkRegistrationType
Definition: elxAdaGrad.h:304
typename itkRegistrationType::TransformType TransformType
Definition: elxAdaGrad.h:305
void BeforeEachResolution() override
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
void BeforeRegistration() override
SizeValueType m_NumberOfJacobianMeasurements
Definition: elxAdaGrad.h:362
typename RegistrationType::FixedImageType FixedImageType
Definition: elxAdaGrad.h:298
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Definition: elxAdaGrad.h:337
SizeValueType m_NumberOfGradientMeasurements
Definition: elxAdaGrad.h:361
void ResumeOptimization() override
typename PreconditionerEstimationType::Pointer PreconditionerEstimationPointer
Definition: elxAdaGrad.h:317
double m_NoiseFactor
Definition: elxAdaGrad.h:374
typename RegistrationType::MovingImageType MovingImageType
Definition: elxAdaGrad.h:299
double m_MaximumStepLengthRatio
Definition: elxAdaGrad.h:417
bool m_OriginalButSigmoidToDefault
Definition: elxAdaGrad.h:431
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
typename ElastixType::FixedImageType OutputImageType
Definition: elxAdaGrad.h:313
RandomGeneratorPointer m_RandomGenerator
Definition: elxAdaGrad.h:371
SizeValueType m_MaximumNumberOfSamplingAttempts
Definition: elxAdaGrad.h:420
typename FixedImageType::RegionType FixedImageRegionType
Definition: elxAdaGrad.h:301
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
Definition: elxAdaGrad.h:324
void AdvanceOneStep() override
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Definition: elxAdaGrad.h:326
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition: elxAdaGrad.h:334
double m_ConditionNumber
Definition: elxAdaGrad.h:377
SizeValueType m_PreviousErrorAtIteration
Definition: elxAdaGrad.h:422
double m_MaximumStepLength
Definition: elxAdaGrad.h:416
typename ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
Definition: elxAdaGrad.h:328
SizeValueType m_NumberOfBandStructureSamples
Definition: elxAdaGrad.h:427
SettingsVectorType m_SettingsVector
Definition: elxAdaGrad.h:358
itk::SizeValueType SizeValueType
Definition: elxAdaGrad.h:225
typename AdvancedBSplineDeformableTransformType::Pointer BSplineTransformBasePointer
Definition: elxAdaGrad.h:355
typename FixedImageType::IndexType FixedImageIndexType
Definition: elxAdaGrad.h:302
SizeValueType m_CurrentNumberOfSamplingAttempts
Definition: elxAdaGrad.h:421
ITK_DISALLOW_COPY_AND_MOVE(AdaGrad)
typename Superclass2::ITKBaseType ITKBaseType
Definition: elxAdaGrad.h:224
void AfterRegistration() override
typename TransformType::JacobianType JacobianType
Definition: elxAdaGrad.h:306
JacobianType TransformJacobianType
Definition: elxAdaGrad.h:343
typename FixedImageType::PointType FixedImagePointType
Definition: elxAdaGrad.h:303
SizeValueType m_NumberOfSpatialSamples
Definition: elxAdaGrad.h:365
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
Definition: elxAdaGrad.h:333
bool m_UseNoiseCompensation
Definition: elxAdaGrad.h:430
void AfterEachResolution() override
~AdaGrad() override=default
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
void StartOptimization() override
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
This class is the elastix base class for all Optimizers.
typename ElastixType::RegistrationBaseType RegistrationType
itk::Optimizer ITKBaseType
typename ITKBaseType::ParametersType ParametersType
A specialized Command object for updating the progress of a filter.
itk::SmartPointer< Self > Pointer
This class implements a gradient descent optimizer with adaptive gain.
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.
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.


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