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 using typename Superclass2::SettingsType;
309 using typename Superclass2::SettingsVectorType;
310 using OutputImageType = typename ElastixType::FixedImageType;
311
315
317
318
331 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
332
334 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
335 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
336
339 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
340 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
341 using CoordinateRepresentationType = typename TransformType::ScalarType;
342
347
351
354
361
364
367
373
378 virtual void
380
388 virtual void
389 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
390
394 virtual void
395 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
396
400 virtual void
401 AddRandomPerturbation(ParametersType & parameters, double sigma);
402
403private:
405
409
415
419
423};
424
425} // end namespace elastix
426
427#ifndef ITK_MANUAL_INSTANTIATION
428# include "elxAdaGrad.hxx"
429#endif
430
431#endif // end #ifndef elxAdaGrad_h
A gradient descent optimizer with an adaptive gain.
Definition elxAdaGrad.h:193
double m_RegularizationKappa
Definition elxAdaGrad.h:371
virtual void AutomaticPreconditionerEstimation()
itk::SmartPointer< Self > Pointer
Definition elxAdaGrad.h:201
typename AdvancedTransformType::Pointer AdvancedTransformPointer
Definition elxAdaGrad.h:345
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
SizeValueType m_MaxBandCovSize
Definition elxAdaGrad.h:417
bool m_AutomaticParameterEstimationDone
Definition elxAdaGrad.h:414
typename ImageRandomSamplerType::Pointer ImageRandomSamplerPointer
Definition elxAdaGrad.h:327
void MetricErrorResponse(itk::ExceptionObject &err) override
SizeValueType m_NumberOfSamplesForPrecondition
Definition elxAdaGrad.h:359
typename JacobianType::ValueType JacobianValueType
Definition elxAdaGrad.h:307
elxClassNameMacro("AdaGrad")
double m_GlobalStepSize
Definition elxAdaGrad.h:370
AdvancedTransformPointer m_AdvancedTransform
Definition elxAdaGrad.h:363
typename ImageGridSamplerType::Pointer ImageGridSamplerPointer
Definition elxAdaGrad.h:329
void AfterEachIteration() override
double m_SigmoidScaleFactor
Definition elxAdaGrad.h:368
typename RandomGeneratorType::Pointer RandomGeneratorPointer
Definition elxAdaGrad.h:335
bool m_AutomaticParameterEstimation
Definition elxAdaGrad.h:406
SizeValueType m_NumberOfSamplesForNoiseCompensationFactor
Definition elxAdaGrad.h:358
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition elxAdaGrad.h:346
itk::SmartPointer< const Self > ConstPointer
Definition elxAdaGrad.h:202
typename TransformType::ScalarType CoordinateRepresentationType
Definition elxAdaGrad.h:341
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:357
typename RegistrationType::FixedImageType FixedImageType
Definition elxAdaGrad.h:298
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Definition elxAdaGrad.h:334
SizeValueType m_NumberOfGradientMeasurements
Definition elxAdaGrad.h:356
void ResumeOptimization() override
typename PreconditionerEstimationType::Pointer PreconditionerEstimationPointer
Definition elxAdaGrad.h:314
typename RegistrationType::MovingImageType MovingImageType
Definition elxAdaGrad.h:299
double m_MaximumStepLengthRatio
Definition elxAdaGrad.h:408
bool m_OriginalButSigmoidToDefault
Definition elxAdaGrad.h:422
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
typename ElastixType::FixedImageType OutputImageType
Definition elxAdaGrad.h:310
RandomGeneratorPointer m_RandomGenerator
Definition elxAdaGrad.h:366
SizeValueType m_MaximumNumberOfSamplingAttempts
Definition elxAdaGrad.h:411
typename FixedImageType::RegionType FixedImageRegionType
Definition elxAdaGrad.h:301
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
Definition elxAdaGrad.h:321
void AdvanceOneStep() override
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Definition elxAdaGrad.h:323
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition elxAdaGrad.h:331
double m_ConditionNumber
Definition elxAdaGrad.h:372
typename std::vector< SettingsType > SettingsVectorType
SizeValueType m_PreviousErrorAtIteration
Definition elxAdaGrad.h:413
double m_MaximumStepLength
Definition elxAdaGrad.h:407
typename ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
Definition elxAdaGrad.h:325
SizeValueType m_NumberOfBandStructureSamples
Definition elxAdaGrad.h:418
SettingsVectorType m_SettingsVector
Definition elxAdaGrad.h:353
itk::SizeValueType SizeValueType
Definition elxAdaGrad.h:225
typename AdvancedBSplineDeformableTransformType::Pointer BSplineTransformBasePointer
Definition elxAdaGrad.h:350
typename FixedImageType::IndexType FixedImageIndexType
Definition elxAdaGrad.h:302
SizeValueType m_CurrentNumberOfSamplingAttempts
Definition elxAdaGrad.h:412
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:338
typename FixedImageType::PointType FixedImagePointType
Definition elxAdaGrad.h:303
SizeValueType m_NumberOfSpatialSamples
Definition elxAdaGrad.h:360
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
Definition elxAdaGrad.h:330
bool m_UseNoiseCompensation
Definition elxAdaGrad.h:421
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
typename std::vector< SettingsType > SettingsVectorType
typename ITKBaseType::ParametersType ParametersType
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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo