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 AdaGrad :
192 public OptimizerBase< TElastix >
193{
194public:
195
197 typedef AdaGrad Self;
200 typedef itk::SmartPointer< Self > Pointer;
201 typedef itk::SmartPointer< const Self > ConstPointer;
202
204 itkNewMacro( Self );
205
207 itkTypeMacro( AdaGrad,
208 VoxelWiseASGDOptimizer );
209
214 elxClassNameMacro( "AdaGrad" );
215
218 typedef Superclass1::CostFunctionPointer CostFunctionPointer;
220
229 typedef itk::SizeValueType SizeValueType;
230
233
237 void BeforeRegistration( void ) override;
238
239 void BeforeEachResolution( void ) override;
240
241 void AfterEachResolution( void ) override;
242
243 void AfterEachIteration( void ) override;
244
245 void AfterRegistration( void ) override;
246
250 void StartOptimization( void ) override;
251
253 void AdvanceOneStep( void ) override;
254
259 void ResumeOptimization( void ) override;
260
262 void MetricErrorResponse( itk::ExceptionObject & err ) override;
263
273 itkSetMacro( AutomaticParameterEstimation, bool );
274 itkGetConstMacro( AutomaticParameterEstimation, bool );
275
277 itkSetMacro( MaximumStepLength, double );
278 itkGetConstReferenceMacro( MaximumStepLength, double );
279
281 itkSetClampMacro( RegularizationKappa, double, 0.0, 1.0 );
282 itkGetConstReferenceMacro( RegularizationKappa, double );
283
285 itkSetMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
286 itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
287
288protected :
289
291 ~AdaGrad() override {}
292
294 typedef typename RegistrationType::FixedImageType FixedImageType;
295 typedef typename RegistrationType::MovingImageType MovingImageType;
296
297 typedef typename FixedImageType::RegionType FixedImageRegionType;
298 typedef typename FixedImageType::IndexType FixedImageIndexType;
299 typedef typename FixedImageType::PointType FixedImagePointType;
300 typedef typename RegistrationType::ITKBaseType itkRegistrationType;
301 typedef typename itkRegistrationType::TransformType TransformType;
302 typedef typename TransformType::JacobianType JacobianType;
303 typedef typename JacobianType::ValueType JacobianValueType;
304 struct SettingsType { double a, A, alpha, fmax, fmin, omega; };
305 typedef typename std::vector< SettingsType > SettingsVectorType;
306 typedef typename ElastixType::FixedImageType OutputImageType;
307
311
314
315
320 typedef typename
322 typedef
324 typedef typename
330 typedef typename
333
335 typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
336 typedef typename RandomGeneratorType::Pointer RandomGeneratorPointer;
339
342 itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
343 itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
344 typedef typename TransformType::ScalarType CoordinateRepresentationType;
345
348 itkGetStaticConstMacro( FixedImageDimension ),
349 itkGetStaticConstMacro( MovingImageDimension ) > AdvancedTransformType;
351 typedef typename
353
356 itkGetStaticConstMacro( FixedImageDimension )> AdvancedBSplineDeformableTransformType;
358
361
368
371
374
380
382 virtual void CheckForAdvancedTransform( void );
383
385 virtual void PrintSettingsVector( const SettingsVectorType & settings ) const;
386
392
400 virtual void SampleGradients( const ParametersType & mu0,
401 double perturbationSigma, double & gg, double & ee );
402
407 const ParametersType & parameters, DerivativeType & derivative );
408
412 virtual void AddRandomPerturbation( ParametersType & parameters, double sigma );
413
414private:
415
416 AdaGrad( const Self & ); // purposely not implemented
417 void operator=( const Self & ); // purposely not implemented
418
422
428
432
436
437};
438
439} // end namespace elastix
440
441#ifndef ITK_MANUAL_INSTANTIATION
442#include "elxAdaGrad.hxx"
443#endif
444
445#endif // end #ifndef __elxAdaGrad_h
A gradient descent optimizer with an adaptive gain.
Definition: elxAdaGrad.h:193
RegistrationType::MovingImageType MovingImageType
Definition: elxAdaGrad.h:295
ImageGridSamplerType::Pointer ImageGridSamplerPointer
Definition: elxAdaGrad.h:329
Superclass1::StopConditionType StopConditionType
Definition: elxAdaGrad.h:219
~AdaGrad() override
Definition: elxAdaGrad.h:291
ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
Definition: elxAdaGrad.h:325
ElastixType::FixedImageType OutputImageType
Definition: elxAdaGrad.h:306
double m_RegularizationKappa
Definition: elxAdaGrad.h:378
RegistrationType::FixedImageType FixedImageType
Definition: elxAdaGrad.h:294
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
AdaGrad(const Self &)
itk::ComputePreconditionerUsingDisplacementDistribution< FixedImageType, TransformType > PreconditionerEstimationType
Definition: elxAdaGrad.h:309
itk::SmartPointer< const Self > ConstPointer
Definition: elxAdaGrad.h:201
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition: elxAdaGrad.h:352
AdvancedTransformType::Pointer AdvancedTransformPointer
Definition: elxAdaGrad.h:350
itk::AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType
Definition: elxAdaGrad.h:349
void operator=(const Self &)
SizeValueType m_MaxBandCovSize
Definition: elxAdaGrad.h:430
itk::ComputeDisplacementDistribution< FixedImageType, TransformType > ComputeDisplacementDistributionType
Definition: elxAdaGrad.h:313
ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
Definition: elxAdaGrad.h:331
bool m_AutomaticParameterEstimationDone
Definition: elxAdaGrad.h:427
void MetricErrorResponse(itk::ExceptionObject &err) override
SizeValueType m_NumberOfSamplesForPrecondition
Definition: elxAdaGrad.h:366
itk::ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
Definition: elxAdaGrad.h:319
std::vector< SettingsType > SettingsVectorType
Definition: elxAdaGrad.h:305
elxClassNameMacro("AdaGrad")
OptimizerBase< TElastix > Superclass2
Definition: elxAdaGrad.h:199
double m_GlobalStepSize
Definition: elxAdaGrad.h:377
AdvancedTransformPointer m_AdvancedTransform
Definition: elxAdaGrad.h:370
JacobianType::ValueType JacobianValueType
Definition: elxAdaGrad.h:303
RegistrationType::ITKBaseType itkRegistrationType
Definition: elxAdaGrad.h:300
ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition: elxAdaGrad.h:332
TransformType::ScalarType CoordinateRepresentationType
Definition: elxAdaGrad.h:344
void AfterEachIteration(void) override
Superclass2::RegistrationType RegistrationType
Definition: elxAdaGrad.h:226
ProgressCommand ProgressCommandType
Definition: elxAdaGrad.h:337
void BeforeEachResolution(void) override
AdaptiveStepsizeOptimizer Superclass1
Definition: elxAdaGrad.h:198
itkRegistrationType::TransformType TransformType
Definition: elxAdaGrad.h:301
double m_SigmoidScaleFactor
Definition: elxAdaGrad.h:375
bool m_AutomaticParameterEstimation
Definition: elxAdaGrad.h:419
virtual void AutomaticPreconditionerEstimation(void)
SizeValueType m_NumberOfSamplesForNoiseCompensationFactor
Definition: elxAdaGrad.h:365
void AdvanceOneStep(void) override
ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Definition: elxAdaGrad.h:321
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType
Definition: elxAdaGrad.h:323
Superclass2::ElastixType ElastixType
Definition: elxAdaGrad.h:222
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
SizeValueType m_NumberOfJacobianMeasurements
Definition: elxAdaGrad.h:364
RandomGeneratorType::Pointer RandomGeneratorPointer
Definition: elxAdaGrad.h:336
void StartOptimization(void) override
SizeValueType m_NumberOfGradientMeasurements
Definition: elxAdaGrad.h:363
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Definition: elxAdaGrad.h:335
itk::SizeValueType SizeValueType
Definition: elxAdaGrad.h:229
double m_NoiseFactor
Definition: elxAdaGrad.h:376
itk::ImageRandomSampler< FixedImageType > ImageRandomSamplerType
Definition: elxAdaGrad.h:326
FixedImageType::PointType FixedImagePointType
Definition: elxAdaGrad.h:299
Superclass2::ITKBaseType ITKBaseType
Definition: elxAdaGrad.h:228
Superclass1::CostFunctionPointer CostFunctionPointer
Definition: elxAdaGrad.h:218
double m_MaximumStepLengthRatio
Definition: elxAdaGrad.h:421
FixedImageType::RegionType FixedImageRegionType
Definition: elxAdaGrad.h:297
bool m_OriginalButSigmoidToDefault
Definition: elxAdaGrad.h:435
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
RandomGeneratorPointer m_RandomGenerator
Definition: elxAdaGrad.h:373
void AfterRegistration(void) override
SizeValueType m_MaximumNumberOfSamplingAttempts
Definition: elxAdaGrad.h:424
itk::AdvancedBSplineDeformableTransformBase< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension)> AdvancedBSplineDeformableTransformType
Definition: elxAdaGrad.h:356
Superclass2::RegistrationPointer RegistrationPointer
Definition: elxAdaGrad.h:227
Superclass1::CostFunctionType CostFunctionType
Definition: elxAdaGrad.h:217
TransformType::JacobianType JacobianType
Definition: elxAdaGrad.h:302
double m_ConditionNumber
Definition: elxAdaGrad.h:379
ProgressCommand::Pointer ProgressCommandPointer
Definition: elxAdaGrad.h:338
SizeValueType m_PreviousErrorAtIteration
Definition: elxAdaGrad.h:426
double m_MaximumStepLength
Definition: elxAdaGrad.h:420
SizeValueType m_NumberOfBandStructureSamples
Definition: elxAdaGrad.h:431
PreconditionerEstimationType::Pointer PreconditionerEstimationPointer
Definition: elxAdaGrad.h:310
SettingsVectorType m_SettingsVector
Definition: elxAdaGrad.h:360
virtual void CheckForAdvancedTransform(void)
Superclass2::ConfigurationPointer ConfigurationPointer
Definition: elxAdaGrad.h:225
JacobianType TransformJacobianType
Definition: elxAdaGrad.h:341
ImageRandomSamplerType::Pointer ImageRandomSamplerPointer
Definition: elxAdaGrad.h:327
SizeValueType m_CurrentNumberOfSamplingAttempts
Definition: elxAdaGrad.h:425
AdvancedBSplineDeformableTransformType::Pointer BSplineTransformBasePointer
Definition: elxAdaGrad.h:357
void AfterEachResolution(void) override
itk::ImageSamplerBase< FixedImageType > ImageSamplerBaseType
Definition: elxAdaGrad.h:317
Superclass2::ConfigurationType ConfigurationType
Definition: elxAdaGrad.h:224
itk::ImageGridSampler< FixedImageType > ImageGridSamplerType
Definition: elxAdaGrad.h:328
ImageSamplerBaseType::Pointer ImageSamplerBasePointer
Definition: elxAdaGrad.h:318
itk::SmartPointer< Self > Pointer
Definition: elxAdaGrad.h:200
Superclass2::ElastixPointer ElastixPointer
Definition: elxAdaGrad.h:223
void ResumeOptimization(void) override
FixedImageType::IndexType FixedImageIndexType
Definition: elxAdaGrad.h:298
Superclass1::ParametersType ParametersType
Definition: elxAdaGrad.h:232
SizeValueType m_NumberOfSpatialSamples
Definition: elxAdaGrad.h:367
void BeforeRegistration(void) override
bool m_UseNoiseCompensation
Definition: elxAdaGrad.h:434
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
A class that deals with user given parameters and command line arguments.
This class is the elastix base class for all Optimizers.
Superclass::ConfigurationPointer ConfigurationPointer
itk::Optimizer ITKBaseType
Superclass::ElastixType ElastixType
Superclass::ElastixPointer ElastixPointer
Superclass::RegistrationPointer RegistrationPointer
Superclass::RegistrationType RegistrationType
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.
Superclass::CostFunctionType CostFunctionType
Superclass::StopConditionType StopConditionType
Superclass::ParametersType ParametersType
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 1667476801 for elastix by doxygen 1.9.4 elastix logo