필터 지우기
필터 지우기

Lsqnonlin optimization unexpected behavior

조회 수: 2 (최근 30일)
AD
AD 2021년 5월 11일
답변: Alan Weiss 2021년 5월 11일
Hello,
I am experimenting with lsqnonlin, first with a very simple problem: make lsqnonlin find translation params. I have an "original" image I, appy translations and then try to make lsqnonlin find them: results of lsqnonlin are in txy_sol_lsqnonlin.
The problem is that it almost immediately stops and always gives me useless results i.e. the same init values that I give it + maybe 0.5 or something like if it can't do more than a few steps and immediately stop searching anymore... Please help me find the problem.
The full code is :
I = phantom(256);
tx=22;
ty=5;
I_tr = imtranslate(I,[tx ty]);
fun = @(txy) [reshape( imtranslate(I,[txy(1) txy(2)])-I_tr,[],1) ];
lsqnonlinoptions=optimset('Algorithm','Levenberg-Marquardt','MaxIter',1000,'Display','iter');
tx_init = 0;
ty_init = 0;
[txy_sol_lsqnonlin,resnorm,residual,exitflag,output] = lsqnonlin(fun,[tx_init, ty_init],[],[],lsqnonlinoptions);
% the Output in Matlab console is:
%
% First-Order Norm of
% Iteration Func-count Residual optimality Lambda step
% 0 3 5058.12 410 0.01
% 1 6 4752.75 58.7 0.001 0.572352
% 2 9 4738.31 1.21 0.0001 0.177726
% 3 12 4738.3 0.00463 1e-05 0.00236374
% 4 15 4738.3 2.41e-05 1e-06 1.27094e-05
%
% So it seems clear that it thinks it has reached an optimum but why?
  댓글 수: 1
AD
AD 2021년 5월 11일
I tried to change tolerance values with 'TolX' but it does not seem to be related to this ...

댓글을 달려면 로그인하십시오.

답변 (1개)

Alan Weiss
Alan Weiss 2021년 5월 11일
lsqnonlin is a gradient-based solver. It first attempts to estimate the local gradient by small finite difference steps. If your function is locally constant, such as a step function, then lsqnonlin sees zero gradient and stops.
To have your function not look like a step function, perhaps you can interpolate it using interp2, for example.
Alan Weiss
MATLAB mathematical toolbox documentation

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by