-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo_ATD_synthetic_comparison.m
286 lines (227 loc) · 9.28 KB
/
demo_ATD_synthetic_comparison.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
clear; clc; close all;
run_path;
n_exp = 1;
tensor_dim = [20 20 20 500];
tucker_rank = [2 2 2 2];
fac_noise = 1e-2;
sampling = 0.7;
mag = 0;
epsilon = mag*ones(1,tensor_dim(end));
lambda = 0.7;
%% metrices
PER_ATD = zeros(size(tensor_dim,2)+1,tensor_dim(end));
PER_ALSaS = zeros(size(tensor_dim,2)+1,tensor_dim(end));
PER_iHOOI = zeros(size(tensor_dim,2)+1,tensor_dim(end));
PER_WTucker = zeros(size(tensor_dim,2)+1,tensor_dim(end));
fprintf('Processing ... ')
for k = 1 : n_exp
%% Generate Tensor
[Xtrue_cell,Factor_True] = tucker_generate_tensor(tensor_dim,tucker_rank,0,epsilon);
OPTS.Factor_True = Factor_True;
OPTS.Slide_True = Xtrue_cell;
OPTS.lambda = lambda;
% Missing + Gaussian Noise
X_cell = cell(tensor_dim(end),1);
Omega = cell(tensor_dim(end),1);
for t = 1 : tensor_dim(end)
Omega_t = rand(tensor_dim(1:end-1));
Omega_t = 1 .* (Omega_t <= sampling);
Omega{t,1} = Omega_t;
X_cell{t,1} = Xtrue_cell{t,1} + fac_noise*randn(tensor_dim(1:end-1));
X_cell_Miss{t,1} = Omega_t .* X_cell{t,1};
end
%% Online Algorithm
X_miss = zeros(tensor_dim);
X_true = zeros(tensor_dim);
Omega_full = zeros(tensor_dim);
for ii = 1:tensor_dim(end)
X_miss(:,:,:,ii) = X_cell_Miss{ii,1};
X_true(:,:,:,ii) = X_cell{ii,1};
Omega_full(:,:,:,ii) = Omega{ii,1};
end
OPTS2.Xtrue = X_true;
t_start = tic;
[~,PER] = ATD(X_cell_Miss,Omega,tucker_rank,OPTS);
t_end = toc(t_start);
PER_ATD = PER;
fprintf(' + ATD (Proposed): %f(s) \n',t_end)
%% Batch Algorithm
t_start = tic;
[~,PER] = ALSaS_Batch(X_cell_Miss,tucker_rank,OPTS);
t_end = toc(t_start);
fprintf(' + ALSaS: %f(s) \n',t_end)
PER_ALSaS = PER_ALSaS + PER;
t_start = tic;
[~,PER] = iHOOI_Batch(X_cell_Miss,tucker_rank,OPTS);
t_end = toc(t_start);
fprintf(' + iHOOI: %f(s) \n',t_end)
PER_iHOOI = PER_iHOOI + PER;
t_start = tic;
[~,PER] = WTucker_Batch(X_cell,tucker_rank,OPTS);
t_end = toc(t_start);
PER_WTucker = PER_WTucker + PER;
fprintf(' + WTucker: %f(s) \n',t_end)
end
PER_ATD = PER_ATD/n_exp;
PER_WTucker = PER_WTucker/n_exp;
PER_ALSaS = PER_ALSaS/n_exp;
PER_iHOOI = PER_iHOOI/n_exp;
% PLOT RESULTS
makerSize = 14;
numbMarkers = 50;
LineWidth = 2;
set(0, 'defaultTextInterpreter', 'latex');
color = get(groot,'DefaultAxesColorOrder');
red_o = [1,0,0];
blue_o = [0, 0, 1];
gree_o = 'g'; %[0, 0.5, 0];
black_o = [0.25, 0.25, 0.25];
blue_n = color(1,:);
oran_n = color(2,:);
yell_n = color(3,:);
viol_n = color(4,:);
gree_n = color(5,:);
lblu_n = color(6,:);
brow_n = color(7,:);
lbrow_n = [0.5350 0.580 0.2840];
%%
fig = figure;
k = 5;
K = tensor_dim(end);
KL = 50;
subplot(311);
hold on;
d2 = semilogy(1:k:K,PER_iHOOI(4,1:k:end),...
'linestyle','-','color',blue_o,'LineWidth',LineWidth);
d21 = plot(1:100:K,PER_iHOOI(4,1:100:end),...
'marker','o','markersize',makerSize,...
'linestyle','none','color',blue_o,'LineWidth',2);
d22 = semilogy(1:1,PER_iHOOI(4,1),...
'marker','o','markersize',makerSize,...
'linestyle','-','color',blue_o,'LineWidth',2);
d3 = semilogy(1:k:K,PER_ALSaS(4,1:k:end),...
'linestyle','-','color',gree_o,'LineWidth',LineWidth);
d31 = plot(1:100:K,PER_ALSaS(4,1:100:end),...
'marker','s','markersize',makerSize,...
'linestyle','none','color',gree_o,'LineWidth',2);
d32 = semilogy(1:1,PER_ALSaS(4,1:1),...
'marker','s','markersize',makerSize,...
'linestyle','-','color',gree_o,'LineWidth',2);
d4 = semilogy(1:k:K,PER_WTucker(4,1:k:end),...
'linestyle','-','color',viol_n,'LineWidth',LineWidth);
d41 = plot(1:100:K,PER_WTucker(4,1:100:end),...
'marker','h','markersize',makerSize,...
'linestyle','none','color',viol_n,'LineWidth',2);
d42 = semilogy(1:1,PER_WTucker(4,1:1),...
'marker','h','markersize',makerSize,...
'linestyle','-','color',viol_n,'LineWidth',2);
d1 = semilogy(1:k:K,PER_ATD(4,1:k:end),...
'linestyle','-','color',red_o,'LineWidth',LineWidth);
d11 = plot(1:100:K,PER_ATD(4,1:100:end),...
'marker','d','markersize',makerSize,...
'linestyle','none','color',red_o,'LineWidth',2);
d12 = semilogy(1:1,PER_ATD(4,1),...
'marker','d','markersize',makerSize,...
'linestyle','-','color',red_o,'LineWidth',2);
lgd = legend([d22 d32 d42 d12],'\texttt{iHOOI}','\texttt{ALSaS}','\texttt{WTucker}','\texttt{ATD(Proposed)}');
lgd.FontSize = 16;
set(lgd, 'Interpreter', 'latex', 'Color', [0.95, 0.95, 0.95]);
ylabel('RE $(\mathcal{X}_{tr}, \mathcal{X}_{es})$','interpreter','latex','FontSize',13,'FontName','Times New Roman');
%
h=gca;
set(gca, 'YScale', 'log');
set(h,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle','-','MinorGridLineStyle','-','FontName','Times New Roman');
set(h,'Xtick',0:KL:K,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle',':','MinorGridLineStyle','none',...
'FontName','Times New Roman');
set(h,'FontSize', 16);
grid on;
box on;
subplot(312);
hold on;
d2 = semilogy(1:k:K,PER_iHOOI(1,1:k:end),...
'linestyle','-','color',blue_o,'LineWidth',LineWidth);
d21 = plot(1:100:K,PER_iHOOI(1,1:100:end),...
'marker','o','markersize',makerSize,...
'linestyle','none','color',blue_o,'LineWidth',2);
d22 = semilogy(1:1,PER_iHOOI(1,1),...
'marker','o','markersize',makerSize,...
'linestyle','-','color',blue_o,'LineWidth',2);
d3 = semilogy(1:k:K,PER_ALSaS(1,1:k:end),...
'linestyle','-','color',gree_o,'LineWidth',LineWidth);
d31 = plot(1:100:K,PER_ALSaS(1,1:100:end),...
'marker','s','markersize',makerSize,...
'linestyle','none','color',gree_o,'LineWidth',2);
d32 = semilogy(1:1,PER_ALSaS(1,1:1),...
'marker','s','markersize',makerSize,...
'linestyle','-','color',gree_o,'LineWidth',2);
d4 = semilogy(1:k:K,PER_WTucker(1,1:k:end),...
'linestyle','-','color',viol_n,'LineWidth',LineWidth);
d41 = plot(1:100:K,PER_WTucker(1,1:100:end),...
'marker','h','markersize',makerSize,...
'linestyle','none','color',viol_n,'LineWidth',2);
d42 = semilogy(1:1,PER_WTucker(1,1:1),...
'marker','h','markersize',makerSize,...
'linestyle','-','color',viol_n,'LineWidth',2);
d1 = semilogy(1:k:K,PER_ATD(1,1:k:end),...
'linestyle','-','color',red_o,'LineWidth',LineWidth);
d11 = plot(1:100:K,PER_ATD(1,1:100:end),...
'marker','d','markersize',makerSize,...
'linestyle','none','color',red_o,'LineWidth',2);
d12 = semilogy(1:1,PER_ATD(1,1),...
'marker','d','markersize',makerSize,...
'linestyle','-','color',red_o,'LineWidth',2);
ylabel('SEP $(\mathbf{U}_{tr}, \mathbf{U}_{es})$','interpreter','latex','FontSize',13,'FontName','Times New Roman');
%
h=gca;
set(gca, 'YScale', 'log');
set(h,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle','-','MinorGridLineStyle','-','FontName','Times New Roman');
set(h,'Xtick',0:KL:K,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle',':','MinorGridLineStyle','none',...
'FontName','Times New Roman');
set(h,'FontSize', 16);
grid on;
box on;
subplot(313)
hold on;
d2 = semilogy(1:k:K,PER_iHOOI(5,1:k:end),...
'linestyle','-','color',blue_o,'LineWidth',LineWidth);
d21 = plot(1:100:K,PER_iHOOI(5,1:100:end),...
'marker','o','markersize',makerSize,...
'linestyle','none','color',blue_o,'LineWidth',2);
d22 = semilogy(1:1,PER_iHOOI(5,1),...
'marker','o','markersize',makerSize,...
'linestyle','-','color',blue_o,'LineWidth',2);
d3 = semilogy(1:k:K,PER_ALSaS(5,1:k:end),...
'linestyle','-','color',gree_o,'LineWidth',LineWidth);
d31 = plot(1:100:K,PER_ALSaS(5,1:100:end),...
'marker','s','markersize',makerSize,...
'linestyle','none','color',gree_o,'LineWidth',2);
d32 = semilogy(1:1,PER_ALSaS(5,1:1),...
'marker','s','markersize',makerSize,...
'linestyle','-','color',gree_o,'LineWidth',2);
d4 = semilogy(1:k:K,PER_WTucker(5,1:k:end),...
'linestyle','-','color',viol_n,'LineWidth',LineWidth);
d41 = plot(1:100:K,PER_WTucker(5,1:100:end),...
'marker','h','markersize',makerSize,...
'linestyle','none','color',viol_n,'LineWidth',2);
d42 = semilogy(1:1,PER_WTucker(5,1:1),...
'marker','h','markersize',makerSize,...
'linestyle','-','color',viol_n,'LineWidth',2);
d1 = semilogy(1:k:K,PER_ATD(5,1:k:end),...
'linestyle','-','color',red_o,'LineWidth',LineWidth);
d11 = plot(1:100:K,PER_ATD(5,1:100:end),...
'marker','d','markersize',makerSize,...
'linestyle','none','color',red_o,'LineWidth',2);
d12 = semilogy(1:1,PER_ATD(5,1),...
'marker','d','markersize',makerSize,...
'linestyle','-','color',red_o,'LineWidth',2);
xlabel('Time Index - $t$','interpreter','latex','FontSize',13,'FontName','Times New Roman');
ylabel('Time(s)','interpreter','latex','FontSize',13,'FontName','Times New Roman');
h=gca;
set(gca, 'YScale', 'log');
set(h,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle','-','MinorGridLineStyle','-','FontName','Times New Roman');
set(h,'Xtick',0:KL:K,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle',':','MinorGridLineStyle','none',...
'FontName','Times New Roman');
set(h,'FontSize', 16);
grid on;
box on;
set(fig, 'units', 'inches', 'position', [0.5 0.5 8 7]);