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 struct SettingsType
304 {
305 double a, A, alpha, fmax, fmin, omega;
306 };
307 using SettingsVectorType = typename std::vector<SettingsType>;
308
310
321 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
322
324 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
325 using RandomGeneratorPointer = typename RandomGeneratorType::Pointer;
328
331 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
332 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
333 using CoordinateRepresentationType = typename TransformType::ScalarType;
338
341
344
349
352
355
357
359 virtual void
361
366 virtual void
368
373 virtual void
375
379 virtual void
381
389 virtual void
390 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
391
395 virtual void
396 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
397
401 virtual void
402 AddRandomPerturbation(ParametersType & parameters, double sigma);
403
404private:
406
410
416
420
424};
425
426} // end namespace elastix
427
428#ifndef ITK_MANUAL_INSTANTIATION
429# include "elxAdaptiveStochasticGradientDescent.hxx"
430#endif
431
432#endif // end #ifndef elxAdaptiveStochasticGradientDescent_h
A gradient descent optimizer with an adaptive gain.
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
virtual void AutomaticParameterEstimationUsingDisplacementDistribution()
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
typename RegistrationType::ITKBaseType itkRegistrationType
typename itkRegistrationType::TransformType TransformType
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
typename RandomGeneratorType::Pointer RandomGeneratorPointer
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
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
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.
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 2023-01-13 for elastix by doxygen 1.9.6 elastix logo