-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathsoftth.m
More file actions
65 lines (57 loc) · 1.46 KB
/
softth.m
File metadata and controls
65 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% softth - computes the proximity operator corresponding to the
% trace norm
%
% Syntax
% [vv,ss,nsv]=softth(vv, lambda, nsv, verbose);
%
% See also
% pca, softth_overlap
%
% Reference
% "Estimation of low-rank tensors via convex optimization"
% Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima
% arXiv:1010.0789
% http://arxiv.org/abs/1010.0789
%
% "Statistical Performance of Convex Tensor Decomposition"
% Ryota Tomioka, Taiji Suzuki, Kohei Hayashi, Hisashi Kashima
% NIPS 2011
% http://books.nips.cc/papers/files/nips24/NIPS2011_0596.pdf
%
% Convex Tensor Decomposition via Structured Schatten Norm Regularization
% Ryota Tomioka, Taiji Suzuki
% NIPS 2013
% http://papers.nips.cc/paper/4985-convex-tensor-decomposition-via-structured-schatten-norm-regularization.pdf
%
% Copyright(c) 2010-2014 Ryota Tomioka
% This software is distributed under the MIT license. See license.txt
function [vv,ss,nsv]=softth(vv, lambda, nsv, verbose);
if ~exist('verbose','var')
verbose=0;
end
sz=size(vv);
nsv=min(min(sz),nsv+1);
if verbose
t0=cputime;
fprintf('sz=[%d %d]\n',sz(1), sz(2));
fprintf('nsv=');
end
while 1
if verbose
fprintf('%d/',nsv);
end
[U,S,V]=pca(vv,min(min(sz),nsv),10);
ss=diag(S);
if min(ss)<lambda || nsv==min(sz)
if verbose
fprintf('min(ss)=%g time=%g\n',min(ss), cputime-t0);
end
break;
else
nsv=min(min(sz),round(nsv*2));
end
end
ix=find(ss>=lambda);
ss=ss(ix)-lambda;
vv = U(:,ix)*diag(ss)*V(:,ix)';
nsv=length(ix);