soft thresholding and hard thresholding



今天在看Michael Elad 大牛的论文《On the Role of Sparse and Redundant Representations in Image Processing》中,看到了soft thresholding 和hard thresholding 这两个概念,很是不明白,所以上网查了一些资料,先把网上查的东西贴出来讨论下。

网上资料大体是说这是指两类的函数,分别是软阈值函数和硬阈值函数,在matlab中soft thresholding function 的形式是 soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding ,其中x代表的的输入向量或矩阵,T表示阈值,soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding if x<0, soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding if x>=0; hard thresholding function 的形式是 soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding两者的shrinkage curves 为下图:

 

soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding
这两个thresholding 有什么用处完全不知道,欢迎知道的朋友告知下,在网上到,好像小波变换的时候有用到它们哥俩,还有什么去噪什么的,而我看的Michael的论文提到它们哥俩的时候是在解决优化问题的时候,论文中是这样的,在解决优化问题soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding

的时候,由于上式加号两边的两项是可分离的(separable)(为什么??),the optimization decouples into a set ofindependent scalar problems of the form soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding ,which have particularly simple closed-form solutions in the two notable cases p=0 and p=1, called hard- and soft-thresholding, respectively. 上面是论文上的原话,就是说当p=1的时候,上述优化问题称为软阈值问题,论文中还有个结论就是对于soft thresholding, 阈值应该为λ,而对于hard thresholding,阈值应该是2倍λ的开根号(不是λ开根号的2倍),到目前为止完全不懂。在网上又看到了一个叫Simon Lucey的主页,他里面讲了一些soft thresholding的东西,也弄过来看看,我就不翻译了,直接上英文:Soft thresholding is becoming a very popular tool in computer vision and machine learning. Essentially it allows one to add to take the following objective:soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding, (和上面的p=1相比,那个0.5可有可无吗???)and solve in a very fast fashion using an approach referred to as soft thresholding. Since L1 penalties are being used nearly everywhere at the moment, the property of soft thresholding to efficiently find the solution to the above form becomes very useful。
这个叫Simon的家伙分别使用matlab的凸优化包CVX中的interior point methods 与刚才讲的soft thresholding去解决上面提到的优化问题进行了对比,代码如下,先使用CVX工具箱,

% Function to solve soft thresholding problem using CVX
%
% arg min_{x} ||x - b||_{2}^{2} + lambda*||x||_{1}
%
% Usage:- x = soft_thresh_cvx
%
% where:- <in>
        b = bias vector
        lambda = weighting on the l1 penalty
        <out>
        x = solution         
%
% Written by Simon Lucey 2012

% 不得不佩服老外做事的认真严谨,随便写个函数看上面的注释就看出来了
function x = soft_thresh_cvx(b,lambda)

M = length(b);
cvx_begin
    cvx_quiet(true);
    variable x(M,1);
    minimize( sum_square(x - b) + lambda*norm(x,1));
cvx_end

根据作者说上述方法很费时,下面贴上使用了soft thresholding方法的code。

先定义soft thresholding operator。


soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding

其实就是本文最开始的时候的soft thresholding function中x=b,T=0.5λ的分段形式,但是这里的阈值取的却是0.5λ,这和上文Michael论文中结论说soft thresholding 阈值应该取λ不符,难道是因为这里的2范数之前没有那个1/2的原因吗??函数代码如下:

% Function to solve soft thresholding problem
%
% arg min_{x} ||x - b||_{2}^{2} + lambda*||x||_{1}
%
% Usage:- x = soft_thresh
%
% where:- <in>
        b = bias vector
        lambda = weighting on the l1 penalty
        <out>
        x = solution         
%
% Written by Simon Lucey 2012
function x = soft_thresh(b,lambda)

% Set the threshold
th = lambda/2;

% First find elements that are larger than the threshold
k = find(b > th);
x(k) = b(k) - th;

% Next find elements that are less than abs
k = find(abs(b) <= th);
x(k) = 0;

% Finally find elements that are less than -th
k = find(b < -th);
x(k) = b(k) + th;
x = x(:);

或者上述函数也可以更简洁的用一句matlab代码表示:

soft_thresh = @(b,lambda) sign(b).*max(abs(b) - lambda/2,0); %对matlab比较精通的同学可以解释下。
下面进行对比:

b = [-0.8487   -0.3349    0.5528    1.0391   -1.1176]';
lambda=2;

 

soft_thresh(b, lambda)

ans =

         0
         0
         0
    0.0391
   -0.1176

 

soft_thresh_cvx(b, lambda)

ans =

   -0.0000
   -0.0000
    0.0000
    0.0391
   -0.1176

可以看到,两者产生的结果完全一样,我自己也在自己的电脑上试验了一下,前提是需要安装斯坦福大学的凸优化解决包CVX,试验结果和simon的完全一样,CVX的解决时间为0.263894秒,而soft thresholding的时间仅仅为0.002016秒,快了130倍!!!

作者Simon在最后提醒说soft thresholding不能简单的用来解决下面形式的问题,soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding
我看Michael 的那篇论文中也说了不能上面形式的问题,Michael只是简单的说由于A的存在,加号两边不具有可分离性了,所以不能使用soft thresholding了,而Simon说由于A将x进行了一个空间旋转,我们不得不使用更慢的CVX来解决上面的问题,但是好消息是最近被证明Augmented Lagragian Methods(不知道什么东东)可用于避免这一问题,并允许继续使用高效的soft thresholding。具体的我就不清楚了。。。哎,数学不好害死人啊,什么时候才能达到大牛们的高度啊。soft <wbr>thresholding <wbr>and <wbr>hard <wbr>thresholding

暂时先写到这吧,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值