Contents
Generate synthetic 3-order tensor
Nway = [50,50,50];
coreNway = [5,5,5];
G = tensor(max(0,randn(coreNway)));
A = cell(1,ndims(G));
for i = 1:ndims(G)
A{i} = max(0,randn(Nway(i),coreNway(i)));
end
Mtrue = full(ttensor(G,A)); N = ndims(Mtrue);
sn = 60;
Noise = tensor(max(0,randn(Nway)));
M = Mtrue + 10^(-sn/20)*norm(Mtrue)/norm(Noise)*Noise;
Solve problem
opts.maxit = 1000; opts.tol = 1e-4;
t0 = tic;
[A,C,Out] = ntd(M,coreNway,opts);
time = toc(t0);
Iteration: 582
Reporting
relerr = norm(full(ttensor(C,A))-Mtrue)/norm(Mtrue);
fprintf('time = %4.2e, ',time);
fprintf('solution relative error = %4.2e\n\n',relerr);
figure;
semilogy(1:Out.iter, Out.hist_obj,'k-','linewidth',2);
xlabel('iteration','fontsize',12);
ylabel('objective value','fontsize',12)
figure;
semilogy(1:Out.iter, Out.hist_rel(2,:),'k-','linewidth',2);
xlabel('iteration','fontsize',12);
ylabel('relative residual','fontsize',12)
time = 2.80e+000, solution relative error = 5.00e-004