chinandy的个人博客分享 http://blog.sciencenet.cn/u/chinandy

博文

Orthogonal Matching Pursuit(OMP)正交匹配追踪算法学习笔记

已有 34118 次阅读 2013-1-14 20:53 |个人分类:模式识别|系统分类:科研笔记| 学习, normal, 微软雅黑

最近学习K-SVD算法的过程中,稀疏编码部分使用了OMP追踪算法,特作此总结。
求解问题:
其中D是过完备的字典,已经给定,Y是原始信号,X待求。
OMP算法的本质思想是:以贪婪迭代的方法选择D的列,使得在每次迭代的过程中所选择的列与当前冗余向量最大程度的相关,从原始信号向量中减去相关部分并反复迭代,只到迭代次数达到稀疏度K,停止迭代。
核心算法步骤如下:
相关Matlab代码如下:
function [A]=OMP(D,X,L); 
%=============================================
% Sparse coding of a group of signals based on a given 
% dictionary and specified number of atoms to use. 
% ||X-DA||
% input arguments: 
%       D - the dictionary (its columns MUST be normalized).
%       X - the signals to represent
%       L - the max. number of coefficients for each signal.
% output arguments: 
%       A - sparse coefficient matrix.
%=============================================
[n,P]=size(X);
[n,K]=size(D);
for k=1:1:P,
    a=[];
    x=X(:,k);                            %the kth signal sample
    residual=x;                        %initial the residual vector
    indx=zeros(L,1);                %initial the index vector

     %the jth iter
    for j=1:1:L,
        
        %compute the inner product
        proj=D'*residual;            
        
        %find the max value and its index
        [maxVal,pos]=max(abs(proj));

        %store the index
        pos=pos(1);
        indx(j)=pos;                    
        
        %solve the Least squares problem.
        a=pinv(D(:,indx(1:j)))*x;    

        %compute the residual in the new dictionary
        residual=x-D(:,indx(1:j))*a;    

        
%the precision is fill our demand.
%         if sum(residual.^2) < 1e-6
%             break;
%         end
    end;
    temp=zeros(K,1);
    temp(indx(1:j))=a;
    A(:,k)=sparse(temp);
end;
return;


https://blog.sciencenet.cn/blog-810210-653094.html


下一篇:如何在64位Matlab中调用C/C++处理大容量数据(largeArrayDims)
收藏 IP: 222.190.117.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (3 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-18 22:19

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部