-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexperiment_cnn_xfold_all.m
75 lines (64 loc) · 1.87 KB
/
experiment_cnn_xfold_all.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
clc
clear all
close all
format compact
global LOG
p = config('cnn_xfold.log');
% matlab CNN
p.mat_cnn_layers = [imageInputLayer([p.cnn_img_size 1]);
convolution2dLayer([4 4],16);
reluLayer();
maxPooling2dLayer(2,'Stride',2);
fullyConnectedLayer(4);
softmaxLayer();
classificationLayer()];
p.mat_cnn_options = trainingOptions(...
'sgdm', ...
'InitialLearnRate', 0.01, ...
'Momentum', 0.1, ...
'Verbose', true, ...
'Shuffle', 'once', ...
'MiniBatchSize', 128, ...
'MaxEpochs', 200);
%% run experiment
feats = {
@mean_signal_power, ...
@mean_var_features, ...
@mean_window_power, ...
@pca_features, ...
@mean_bp_features,...
@fft_power_features,...
@dct_features,...
@mean_tdp_features,...
@mean_teager_features,...
@plain_fft_features,...
@plain_wavelet_features,...
@plain_signal_features, ...
@energy_map_features, ...
};
outname = 'xfold_all';
results = cell(1,numel(feats));
elapsed = [];
t_init = tic();
for i=1:numel(feats)
try
t0 = tic();
func = feats{i};
LOG.info('Evaluating: %s', func2str(func));
[x, xfold] = run_experiment(func, @classify_matcnn, p);
r = {};
r.feats = func;
r.class = @classify_matcnn;
r.x = x;
r.xfold = xfold;
results{i} = r;
save(sprintf('cnn_results/%s.mat', outname), 'results');
elapsed = mean([elapsed toc(t0)]);
LOG.info('Evaluation step %d/%d done. Elapsed: %.4f sec, approx. time remaining: %.4f sec', ...
i, numel(feats), elapsed, (numel(feats)-i) * elapsed);
catch e
LOG.error('exception caught: %s', e.message);
display(e);
end
end
LOG.info('Done. Total time: %.4f sec', toc(t_init));