-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_autoencoder.m
71 lines (54 loc) · 1.39 KB
/
train_autoencoder.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
clear
%%
load('ground_sensor_data.mat', 'ground', 'params','Emitters');
%%
i = 1;
for xi = 1: size(ground,1)
for yi = 1:size(ground,2)
temp_data = ground(xi,yi).Y_data;he
temp_data_noise = ground(xi,yi).Ynoise_data;
for em_i = 1:params.n_Emitters
data(i).sensor = reshape(temp_data(:,em_i),params.Np, params.Nm)*255;
data_noise(i).sensor = reshape(temp_data_noise(:,em_i),params.Np, params.Nm)*255;
emitter_data(:,i) = Emitters(rem(i-1,params.n_Emitters)+1).HTM(1:3,4);
target_data(i).x = ground
i = i+1;
end
end
end
%%
% x = digitsmall_dataset;
x = struct2cell(data(:));
x_noise = struct2cell(data_noise(:));
%%help neural net
hiddenSize = 30;
autoenc = trainAutoencoder(x, hiddenSize, ...
'L2WeightRegularization', 0.001, ... %0.004
'SparsityRegularization', 1.6, ...
'SparsityProportion', 0.5, 'ScaleData',false);
%%
% xReconstructed = predict(autoenc, x);
xReconstructed = predict(autoenc, x);
figure;
offset=200;
for i = 1:20
subplot(4,5,i);
imshow(x{i+offset});
end
figure;
for i = 1:20
subplot(4,5,i);
imshow(xReconstructed{i+offset});
end
xReconstructed = predict(autoenc, x_noise);
figure;
offset=100;
for i = 1:20
subplot(4,5,i);
imshow(x_noise{i+offset});
end
figure;
for i = 1:20
subplot(4,5,i);
imshow(xReconstructed{i+offset});
end