Home > release > test_threshold.m

test_threshold

PURPOSE ^

TEST_THRESHOLD - Computes and plots Figure 2

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 TEST_THRESHOLD - Computes and plots Figure 2

 See also
  PLOTRESULTS

 Reference
 "On the extension of trace norm to tensors"
 Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima
 arXiv:1010.0789
 http://arxiv.org/abs/1010.0789

 Copyright(c) 2010 Ryota Tomioka
 This software is distributed under the MIT license. See license.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % TEST_THRESHOLD - Computes and plots Figure 2
0002 %
0003 % See also
0004 %  PLOTRESULTS
0005 %
0006 % Reference
0007 % "On the extension of trace norm to tensors"
0008 % Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima
0009 % arXiv:1010.0789
0010 % http://arxiv.org/abs/1010.0789
0011 %
0012 % Copyright(c) 2010 Ryota Tomioka
0013 % This software is distributed under the MIT license. See license.txt
0014 
0015 
0016 nrep=10;
0017 nsample = 10;
0018 sz=[50 50 20];
0019 trfrac=0.05:0.05:0.95;
0020 
0021 
0022 for ll=1:nsample
0023   dtrue=round(rand(1,3).*sz);
0024   
0025   err=zeros(nrep, length(trfrac));
0026   gval=zeros(nrep, length(trfrac));
0027 
0028   for kk=1:nrep
0029 
0030     X0=randtensor3(sz,dtrue);
0031     nn=prod(size(X0));
0032 
0033 
0034     for ii=1:length(trfrac)
0035       ntr=round(nn*trfrac(ii));
0036       ind=randperm(nn); ind=ind(1:ntr)';
0037       [I,J,K]=ind2sub(size(X0),ind);
0038       
0039       [X,Z,Y,fval,gvals]=tensorconst_adm(zeros(size(X0)),{I,J,K},X0(ind),0,1);
0040 
0041       err(kk,ii)=norm(X(:)-X0(:));
0042       gval(kk,ii)=gvals(end);
0043       fprintf('frac=%g norm(X-X0)=%g\n', trfrac(ii), err(kk,ii));
0044     end
0045   end
0046 
0047   file_save=sprintf('result_%d_%d_%d_%d_%d_%d.mat',sz(1),sz(2),sz(3),dtrue(1),dtrue(2),dtrue(3));
0048 
0049   save(file_save,'nrep', 'sz', 'dtrue', 'err', 'trfrac','gval');
0050 
0051 end
0052 
0053 S=ls('result_50_50_20_*.mat','-1');
0054 files=split(S,char(10));
0055 [rs, frac, dim]=plotresults(files);

Generated on Wed 22-Dec-2010 16:09:20 by m2html © 2003