LM算法——列文伯格-马夸尔特算法

关于LM写的不错的文章:

https://blog.csdn.net/a6333230/article/details/83304098

三维重构PMP论文中使用的信赖域算法(LM)matlab版,修改在标定中可用

function [G, val] = rect_rot(G, A, d)
% Rectify rotations
%
% G: Rectifying transform
% A, d: Coefficients for orthonormality constraint
% val: Value of residual error

ik = size(G, 1);
ikk = numel(G);
k = ikk/ik;
Id = eye(ik);
IdG = eye(ikk);

% Parameters for trust-region optimization
delta = 1;
eta1 = 1/4;
eta2 = 3/4;
kappa = 2;
epsilon = 1e-3;

% Trust-region strategy
f = A*reshape(G*G', [], 1)-d;
c = norm(f)^2;
pc = inf;
while pc-c > 1e-10
    pG = G;
    pf = f;
    pc = c;

    J = A*kron(G, Id)+reshape(permute(reshape(A*kron(Id, G), [], k, ik), [1 3 2]), [], ikk);
    H = J'*J;
    g = J'*f;

    while true
        temp = H+IdG*delta;
        r = (temp+trace(temp)*1e-10*IdG)\g;
        G(:) = G(:)-r;

        f = A*reshape(G*G', [], 1)-d;
        c = norm(f)^2;

        rho = (pc-c)/(pc-norm(pf-J*r)^2);
        rho(isnan(rho)) = 0;
        if rho < eta1 || pc < c
            delta = delta*kappa;
        elseif rho > eta2
            delta = delta/kappa;
        end

        if rho < epsilon || pc < c
            G = pG;
            if delta > 1e10
                c = pc;
                break;
            end
        else
            break;
        end
    end
end

val = mse(f);

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值