首先声明,MOD不是取模函数!MOD是字典学习和sparse coding的一种方法… 最近在看KSVD,其简化版就是MOD(method of directions),这么说吧,KSVD和MOD的优化目标函数是相同的,MOD之所以可以称作KSVD的简化版是因为KSVD在MOD的基础上做了顺序更新列的优化。关于KSVD和MOD的理论知识请见下面我给出的一页note和referenc中的paper。本文主要给出其基本思想及我的代码,已经过测试,如有bug欢迎提出。
Reference
<<From Sparse Solutions of Systems of Equations to Sparse Modeling of Signals and Images>>, Page 68~70
KSVD & MOD's principle & objective function
Principle:
简单来说,其优化就是一个OMP(orthogonal matching pursuit)与Regression的迭代过程,因此代码包括一个OMP.m, regression.m.
Objective Function & the variation from MOD to KSVD:
Code
CODE1. MOD
运行Main(Main中通过MOD)学习字典和稀疏表示,MOD迭代调用Regression学习字典,调用和OMP获得sparse representation.
Main.m
%% Main.m
clc;
clear;
P = 512;
N = 256;
M = 128;
K = 100;
%% Data Generator Method 1
% sparsity_X = 0.4;
% Y = randi(10,M,P);
% X = floor(sprand(N,P,sparsity_X)*10);
%% Data Generator Method 2
Y = randn(M,P);%Notice that Y should be full rank, that is, rank(Y) = N
X = randn(N,P);% initialization of X
%% Main Iteration
[D,X] = MOD(Y,X,K,1e-4);
MOD.m
% @Function: Method Of Dirction of 2D signal
% For dictionary and sparse representation learning
% @CreateTime: 2013-2-22
% @Author: Rachel Zhang @ http://blog.csdn.net/abcjennifer
%
% @Reference: From Sparse Solutions of Systems of Equations to
% Sparse Modeling of Signals and Images
function [ D , X ] = MOD( Y ,X ,K ,ErrorThreshold )
%MOD Summary of this function goes here
% Detailed explanation goes here
% Sample_Data is Y
% Coefficient is X
% Dictionary is D
% sparsity is K
disp('Run Method of directions');
iteration_time = 1;
error = ErrorThreshold+1;
while error>=ErrorThreshold;
disp(