ITK icon indicating copy to clipboard operation
ITK copied to clipboard

GradientDescentOptimizerv4 can return incorrect positions

Open gregsharp opened this issue 3 years ago • 3 comments

Description

The GradientDescentOptimizerv4 algorithm does not correctly keep track of the score and position (Parameters). This causes issues:

  • When a new best score is found, an incorrect position may be recorded
  • Observer callbacks are made with incorrect position

See Discourse for discussion

https://discourse.itk.org/t/imageregistrationmethodv4-questions/4117/7

Steps to Reproduce

The link below is a test program that reproduces the problem. It needs a bit of work to become a standalone test but should illustrate how to reproduce. At iteration zero, the observer for AmoebaOptimizerv4 correctly reports that the position is zero whereas the observer for RegularStepGradientDescentOptimizerv4 reports the correct score, but the wrong position.

https://gitlab.com/plastimatch/plastimatch/-/blob/master/src/plastimatch/test/itk_registration_v4.cxx

Expected behavior

At iteration zero, the position is zero and so the printout should display

0 17208.6 [0, 0, 0]

Actual behavior

But instead it displays

0 17208.6 [14.999996789911513, -0.006939114154077091, -0.006939116585946947]

Reproducibility

100% reproducible

Versions

ITK 4.12 and 5.1.2 both exhibit this problem. Probably other versions do too.

Environment

Additional Information

gregsharp avatar Jun 02 '21 16:06 gregsharp

The behavior expected here is quite related to a recent additional feature added to SimpleITK to support optimizers "StopOptimization" or "StopRegistration" method.

Here is the SimpleITK PR: https://github.com/SimpleITK/SimpleITK/pull/1407

The test in interesting because it check for the behavior with 7 different v4 optimizers.

Related to this issue, with some optimizers when manually stopping, the last iteration is the best but it is not set and the final best position. This behavior is not consistent across the optimizers. However, for the GradientDecentOptimizerv4 the "correct", best, and last position is the result.

blowekamp avatar Jun 15 '21 13:06 blowekamp

CC @hjmjohnson @ntustison @stnava

thewtex avatar Jun 15 '21 18:06 thewtex

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 11:04 stale[bot]