-
Notifications
You must be signed in to change notification settings - Fork 80
/
very_deep_model.lua
52 lines (43 loc) · 1.54 KB
/
very_deep_model.lua
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
require 'cunn'
require 'ccn2'
-- Very Deep model
function very_deep_model() -- validate.lua Acc: 0.924
local model = nn.Sequential()
local final_mlpconv_layer = nil
-- Convolution Layers
model:add(nn.Transpose({1,4},{1,3},{1,2}))
model:add(ccn2.SpatialConvolution(3, 64, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialConvolution(64, 64, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialMaxPooling(2, 2))
model:add(nn.Dropout(0.25))
model:add(ccn2.SpatialConvolution(64, 128, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialConvolution(128, 128, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialMaxPooling(2, 2))
model:add(nn.Dropout(0.25))
model:add(ccn2.SpatialConvolution(128, 256, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialConvolution(256, 256, 3, 1, 1))
model:add(nn.ReLU())
model:add(ccn2.SpatialMaxPooling(2, 2))
model:add(nn.Dropout(0.25))
-- Fully Connected Layers
model:add(ccn2.SpatialConvolution(256, 1024, 3, 1, 0))
model:add(nn.ReLU())
model:add(nn.Dropout(0.5))
model:add(ccn2.SpatialConvolution(1024, 1024, 1, 1, 0))
model:add(nn.ReLU())
model:add(nn.Dropout(0.5))
model:add(nn.Transpose({4,1},{4,2},{4,3}))
model:add(nn.SpatialConvolutionMM(1024, 10, 1, 1))
model:add(nn.Reshape(10))
model:add(nn.SoftMax())
return model
end