-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathunet_2d.m
More file actions
101 lines (91 loc) · 5.08 KB
/
Copy pathunet_2d.m
File metadata and controls
101 lines (91 loc) · 5.08 KB
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
%define n as number of channels
n = 1;
lgraph = layerGraph();
%% Add Layer Branches
% Add the branches of the network to the layer graph. Each branch is a linear
% array of layers.
tempLayers = [
imageInputLayer([64 64 n],"Name","input","Normalization","none")
batchNormalizationLayer("Name","BN_Module1_Level1")
convolution2dLayer([3 3],32,"Name","conv_Module1_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module1_Level1")
batchNormalizationLayer("Name","BN_Module1_Level2")
convolution2dLayer([3 3],64,"Name","conv_Module1_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module1_Level2")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
maxPooling2dLayer([2 2],"Name","maxpool_Module1","Padding","same","Stride",[2 2])
batchNormalizationLayer("Name","BN_Module2_Level1")
convolution2dLayer([3 3],64,"Name","conv_Module2_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module2_Level1")
batchNormalizationLayer("Name","BN_Module2_Level2")
convolution2dLayer([3 3],128,"Name","conv_Module2_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module2_Level2")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
maxPooling2dLayer([2 2],"Name","maxpool_Module2","Padding","same","Stride",[2 2])
batchNormalizationLayer("Name","BN_Module3_Level1")
convolution2dLayer([3 3],128,"Name","conv_Module3_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module3_Level1")
batchNormalizationLayer("Name","BN_Module3_Level2")
convolution2dLayer([3 3],256,"Name","conv_Module3_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module3_Level2")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
maxPooling2dLayer([2 2],"Name","maxpool_Module3","Padding","same","Stride",[2 2])
batchNormalizationLayer("Name","BN_Module4_Level1")
convolution2dLayer([3 3],256,"Name","conv_Module4_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module4_Level1")
batchNormalizationLayer("Name","BN_Module4_Level2")
convolution2dLayer([3 3],512,"Name","conv_Module4_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module4_Level2")
upsample2dLayer([2 2],512,"Name","upsample_Module4","Stride",[2 2])];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
concatenationLayer(3,2,"Name","concat3")
batchNormalizationLayer("Name","BN_Module5_Level1")
convolution2dLayer([3 3],256,"Name","conv_Module5_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module5_Level1")
batchNormalizationLayer("Name","BN_Module5_Level2")
convolution2dLayer([3 3],256,"Name","conv_Module5_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module5_Level2")
upsample2dLayer([2 2],256,"Name","upsample_Module5","Stride",[2 2])];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
concatenationLayer(3,2,"Name","concat2")
batchNormalizationLayer("Name","BN_Module6_Level1")
convolution2dLayer([3 3],128,"Name","conv_Module6_Level1","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module6_Level1")
batchNormalizationLayer("Name","BN_Module6_Level2")
convolution2dLayer([3 3],128,"Name","conv_Module6_Level2","Padding","same","WeightsInitializer","narrow-normal")
reluLayer("Name","relu_Module6_Level2")
upsample2dLayer([2 2],128,"Name","upsample_Module6","Stride",[2 2])];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
concatenationLayer(3,2,"Name","concat1")
batchNormalizationLayer("Name","BN_Module7_Level1")
convolution2dLayer([3 3],64,"Name","conv_Module7_Level1","Padding","same")
reluLayer("Name","relu_Module7_Level1")
batchNormalizationLayer("Name","BN_Module7_Level2")
convolution2dLayer([3 3],64,"Name","conv_Module7_Level2","Padding","same")
reluLayer("Name","relu_Module7_Level2")
batchNormalizationLayer("Name","BN_Module7_Level3")
convolution2dLayer([1 1],2,"Name","ConvLast_Module7")
softmaxLayer("Name","softmax")
dicePixelClassificationLayer("Name","output")];
lgraph = addLayers(lgraph,tempLayers);
% clean up helper variable
clear tempLayers;
%% Connect Layer Branches
% Connect all the branches of the network to create the network graph.
lgraph = connectLayers(lgraph,"relu_Module1_Level2","maxpool_Module1");
lgraph = connectLayers(lgraph,"relu_Module1_Level2","concat1/in2");
lgraph = connectLayers(lgraph,"relu_Module2_Level2","maxpool_Module2");
lgraph = connectLayers(lgraph,"relu_Module2_Level2","concat2/in2");
lgraph = connectLayers(lgraph,"relu_Module3_Level2","maxpool_Module3");
lgraph = connectLayers(lgraph,"relu_Module3_Level2","concat3/in2");
lgraph = connectLayers(lgraph,"upsample_Module4","concat3/in1");
lgraph = connectLayers(lgraph,"upsample_Module5","concat2/in1");
lgraph = connectLayers(lgraph,"upsample_Module6","concat1/in1");
%% Plot Layers
plot(lgraph);