-
Notifications
You must be signed in to change notification settings - Fork 6
/
experiment_cnn_learn_rate.m
58 lines (46 loc) · 1.46 KB
/
experiment_cnn_learn_rate.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
clc
clear all
close all
format compact
global LOG
p = config('cnn_learn_rate.log');
p.skip_10fold = true;
% 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()];
%% run experiment
outname = 'cnn_learn_rate';
rate = [0.001 0.005 0.01 0.02 0.03 0.05 0.07 0.1 0.2 0.5];
results = cell(1, numel(rate));
elapsed = [];
t_init = tic();
for i=1:numel(rate)
t0 = tic();
p.mat_cnn_options = trainingOptions(...
'sgdm', ...
'InitialLearnRate', rate(i), ...
'Momentum', 0.01, ...
'Verbose', true, ...
'Shuffle', 'once', ...
'MiniBatchSize', 128, ...
'MaxEpochs', 500);
LOG.info('Begin learn rate = %f evaluation', rate(i));
[x, xfold] = run_experiment(@mean_signal_power, @classify_matcnn, p);
r = {};
r.rate = rate(i);
r.feats = @mean_signal_power;
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(rate), elapsed, (numel(rate)-i) * elapsed);
end
LOG.info('Done. Total time: %.4f sec', toc(t_init));