go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxAdaptiveStochasticGradientDescent.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 elxAdaptiveStochasticGradientDescent_h
19#define elxAdaptiveStochasticGradientDescent_h
20
21#include "elxIncludes.h" // include first to avoid MSVS warning
23
24#include "itkComputeJacobianTerms.h" // For ASGD step size
25#include "itkComputeDisplacementDistribution.h" // For FASGD step size
26#include "elxProgressCommand.h"
28#include "itkMersenneTwisterRandomVariateGenerator.h"
29
30
31namespace elastix
32{
192template <class TElastix>
193class ITK_TEMPLATE_EXPORT AdaptiveStochasticGradientDescent
195 , public OptimizerBase<TElastix>
196{
197public:
199
204 using Pointer = itk::SmartPointer<Self>;
205 using ConstPointer = itk::SmartPointer<const Self>;
206
208 itkNewMacro(Self);
209
212
217 elxClassNameMacro("AdaptiveStochasticGradientDescent");
218
220 using Superclass1::CostFunctionType;
221 using Superclass1::CostFunctionPointer;
223
225 using typename Superclass2::ElastixType;
226 using typename Superclass2::RegistrationType;
228 using SizeValueType = itk::SizeValueType;
229
231 using typename Superclass1::ParametersType;
232
236 void
238
239 void
241
242 void
244
245 void
247
248 void
250
254 void
256
261 void
263
265 void
266 MetricErrorResponse(itk::ExceptionObject & err) override;
267
277 itkSetMacro(AutomaticParameterEstimation, bool);
278 itkGetConstMacro(AutomaticParameterEstimation, bool);
279
281 itkSetMacro(MaximumStepLength, double);
282 itkGetConstMacro(MaximumStepLength, double);
283
285 itkSetMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
286
288 itkGetConstReferenceMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
289
290protected:
292 using FixedImageType = typename RegistrationType::FixedImageType;
293 using MovingImageType = typename RegistrationType::MovingImageType;
294
295 using FixedImageRegionType = typename FixedImageType::RegionType;
296 using FixedImageIndexType = typename FixedImageType::IndexType;
297 using FixedImagePointType = typename FixedImageType::PointType;
298 using itkRegistrationType = typename RegistrationType::ITKBaseType;
299 using TransformType = typename itkRegistrationType::TransformType;
300 using JacobianType = typename TransformType::JacobianType;
302 using JacobianValueType = typename JacobianType::ValueType;
303 using typename Superclass2::SettingsType;
304 using typename Superclass2::SettingsVectorType;
306
317 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
318
320 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
321 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
322
325 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
326 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
327 using CoordinateRepresentationType = typename TransformType::ScalarType;
332
335
338
343
346
349
351
356 virtual void
358
363 virtual void
365
369 virtual void
371
379 virtual void
380 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
381
385 virtual void
386 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
387
391 virtual void
392 AddRandomPerturbation(ParametersType & parameters, double sigma);
393
394private:
396
400
406
410
414};
415
416} // end namespace elastix
417
418#ifndef ITK_MANUAL_INSTANTIATION
419# include "elxAdaptiveStochasticGradientDescent.hxx"
420#endif
421
422#endif // end #ifndef elxAdaptiveStochasticGradientDescent_h
A gradient descent optimizer with an adaptive gain.
virtual void AutomaticParameterEstimationUsingDisplacementDistribution()
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
typename itkRegistrationType::TransformType TransformType
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
typename RegistrationType::FixedImageType FixedImageType
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
typename ImageGridSamplerType::Pointer ImageGridSamplerPointer
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
~AdaptiveStochasticGradientDescent() override=default
typename std::vector< SettingsType > SettingsVectorType
elxClassNameMacro("AdaptiveStochasticGradientDescent")
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
typename AdvancedTransformType::Pointer AdvancedTransformPointer
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
ITK_DISALLOW_COPY_AND_MOVE(AdaptiveStochasticGradientDescent)
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
void MetricErrorResponse(itk::ExceptionObject &err) override
typename RegistrationType::MovingImageType MovingImageType
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
typename ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
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.
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 parameter estimation of the ASGD 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.
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