-
Notifications
You must be signed in to change notification settings - Fork 0
/
deep_learning_networks.m
66 lines (53 loc) · 1.88 KB
/
deep_learning_networks.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
clc
clear all
close all
%% Deep learning network (Regression)
inputSize = [7 1 1];
numFeatures = 7;
miniBatchSize = 64;
maxEpochs = 300;
layers = [ ...
imageInputLayer(inputSize,'Name','input','Normalization','none')
convolution2dLayer([3 1],32,'Name','conv1','Padding','same')
batchNormalizationLayer('Name','bn1')
reluLayer('Name','relu1')
convolution2dLayer([2 1],64,'Name','conv2','Padding','same')
batchNormalizationLayer('Name','bn2')
reluLayer('Name','relu2')
fullyConnectedLayer(1, 'Name','fc')
regressionLayer('Name','regression')];
options = trainingOptions('adam', ...
'ExecutionEnvironment','gpu', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.001, ...
'L2Regularization',0.0001, ...
'Shuffle','every-epoch', ...
'Verbose',false,...
'Plots','training-progress');
%% Deep learning network (Classification)
inputSize = [7 1 1];
numFeatures = 7;
numClasses = 3;
miniBatchSize = 64;
maxEpochs = 15;
layers = [ ...
imageInputLayer(inputSize,'Name','input','Normalization','none')
convolution2dLayer([3 1],32,'Name','conv1','Padding','same')
batchNormalizationLayer('Name','bn1')
reluLayer('Name','relu1')
convolution2dLayer([2 1],64,'Name','conv2','Padding','same')
batchNormalizationLayer('Name','bn2')
reluLayer('Name','relu2')
fullyConnectedLayer(numClasses, 'Name','fc')
softmaxLayer('Name','softmax')
classificationLayer('Name','classification')];
options = trainingOptions('adam', ...
'ExecutionEnvironment','gpu', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'InitialLearnRate',0.001, ...
'L2Regularization',0.0001, ...
'Shuffle','every-epoch', ...
'Verbose',false,...
'Plots','training-progress');