-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathplot_denoising.m
More file actions
104 lines (84 loc) · 2.4 KB
/
plot_denoising.m
File metadata and controls
104 lines (84 loc) · 2.4 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
% plot_denoising - plot MSE against normalized rank
%
% Syntax
% [dim1, dim2, dim3,err, lambda]=plot_denoising(files, lmd, style)
%
% See also
% exp_denoising, plot_nips2011, plot_nips2011_final
%
% 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 [dim1, dim2, dim3,err, lambda]=plot_denoising(files, lmd, style)
if ~exist('style','var')
style='x';
end
ns=length(files);
frac=zeros(ns,1);
err=zeros(ns,1);
nn =zeros(ns,1);
for ii=1:ns
S=load(files{ii});
sz(ii,:)=S.sz;
rs(ii,:)=S.dtrue;
if exist('lmd','var')
[mm,ix]=min((log(S.lambda)-log(lmd)).^2);
err(ii)=mean(S.err(:,ix).^2)/prod(S.sz);
lambda(ii)=S.lambda(ix);
else
[err(ii), ix]=min(mean(S.err.^2)/prod(S.sz));
lambda(ii)=S.lambda(ix);
end
end
fprintf('rangeof(lambda)=%s\n',printvec(rangeof(lambda)));
nn=prod(sz,2);
if size(rs,2)>1
rst = [min(rs(:,1), rs(:,2).*rs(:,3)),...
min(rs(:,2), rs(:,1).*rs(:,3)),...
min(rs(:,3), rs(:,1).*rs(:,2))];
else
rst=[rs,rs];
end
% dim=rs*[50 50 20]'+rs(:,1).*rs(:,2).*rs(:,3) -sum(rs.^2,2);
%dim=max(rst,[],2);%sum(rst,2);
% dim=sum(rst,2);
% dim=sum(sqrt(rst./(ones(ns,1)*sz)),2).^2/(size(sz,2)^2*size(rst,2)^2);
dim1=(mean(sqrt(1./sz),2).*mean(sqrt(rst),2)).^2;
dim2=sum(sqrt(sz)+sqrt((nn*ones(1,3))./sz),2);
dim3=sum(sqrt(rst)/size(rst,2),2).^2;
%dim=nm';
% figure;
plot(dim1,err,style,'linewidth',2,'markersize',10);
if 0 % size(rs,2)>1
for ii=1:ns
text(dim(ii),frac(ii),...
sprintf('[%d %d %d]',rs(ii,1),rs(ii,2),rs(ii,3)));
end
end
ix=find(~isnan(err));
p=polyfit(dim1(ix),err(ix),1)
hold on;
plot(xlim,polyval(p,xlim),'--','color',[.5 .5 .5],'linewidth', 2)
h=get(gca,'children');
set(gca,'children',h([2:end,1]));
set(gca,'fontsize',16)
xlabel('Normalized rank')
ylabel('Mean squared error')
grid on;