-
Notifications
You must be signed in to change notification settings - Fork 0
/
als_runs_uber.m
62 lines (49 loc) · 1.43 KB
/
als_runs_uber.m
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
%% Runs of CP-ALS for the Uber tensor
%% User setup for script
do_diary = true; % False to disable diary recording
do_gitchecks = true; % False to disable git repo checks
%% Setup recording when running the entire file
[aname, diaryname, do_diary] = diarysetup(mfilename, do_diary);
%% Check relevant git repos
if do_gitchecks
% Check Tensor Toolbox
tmp = which('tensor');
ttbdir = tmp(1:end-16); % Removing '@tensor\tensor.m'
gitstatus(ttbdir);
% Check this directory
gitstatus(pwd);
end
%% Load in Uber Tensor
nruns = 10;
R = 25;
% Need to change this to be the path on Kahuna
tic;
load ('/home/bwlarse/Tensors/tensor_data_uber/uber_tensor');
toc
fprintf('\n---Loading in Uber Tensor---\n')
sz = size(uber);
N = ndims(uber);
%% Set up output
results = cell(nruns,ns,2);
rng('shuffle')
%% Run cp_leverage
for rep = 1:nruns
fprintf('\n---Starting run %i/%i---\n', rep, nruns)
fprintf('Generating random initialization: \n', rep)
rnginit;
Uinit = cell(N,1);
dimorder = 1:N;
for n = dimorder(2:end)
Uinit{n} = rand(sz(n),R);
end
fprintf('Finding CP decomposition: \n')
rnginit;
tic
[M, ~, info] = cp_als_trace(uber,R, 'init', Uinit);
time = toc;
fprintf('Total Time (secs): %.3f\n', time)
info.params.init = 'removed';
results{rep} = info;
end
% Save out the traces and fits for all runs
save('-v7.3', sprintf('%s-results', aname), 'results')