This repository has been archived by the owner on Jul 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
model_yolo.lua
76 lines (61 loc) · 1.82 KB
/
model_yolo.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--
-- Created by IntelliJ IDEA.
-- User: changqi
-- Date: 3/14/16
-- Time: 1:03 PM
-- To change this template use File | Settings | File Templates.
--
require 'nn'
require 'cunn'
local vgg = nn.Sequential();
-- building block
local function ConvBNReLU(nInputPlane, nOutputPlane)
vgg:add(nn.SpatialConvolution(nInputPlane, nOutputPlane, 3, 3, 1, 1, 1, 1))
vgg:add(nn.SpatialBatchNormalization(nOutputPlane, 1e-3))
vgg:add(nn.ReLU(true))
return vgg
end
local MaxPooling = nn.SpatialMaxPooling
--input: Bx1x448x448
ConvBNReLU(1,64):add(nn.Dropout(0.3));
ConvBNReLU(64,64);
-- Bx64x448x448
vgg:add(MaxPooling(2, 2, 2, 2):ceil());
-- Bx64x224x224
ConvBNReLU(64, 128):add(nn.Dropout(0.4))
ConvBNReLU(128, 128)
vgg:add(MaxPooling(2, 2, 2, 2):ceil())
-- Bx128x112x112
ConvBNReLU(128, 256):add(nn.Dropout(0.4))
ConvBNReLU(256, 256):add(nn.Dropout(0.4))
ConvBNReLU(256, 256)
vgg:add(MaxPooling(2, 2, 2, 2):ceil())
-- Bx256x56x56
ConvBNReLU(256, 512):add(nn.Dropout(0.4))
ConvBNReLU(512, 512):add(nn.Dropout(0.4))
ConvBNReLU(512, 512)
vgg:add(MaxPooling(2, 2, 2, 2):ceil())
-- Bx512x28x28
ConvBNReLU(512, 512):add(nn.Dropout(0.4))
ConvBNReLU(512, 512):add(nn.Dropout(0.4))
ConvBNReLU(512, 512)
vgg:add(MaxPooling(2, 2, 2, 2):ceil())
-- Bx512x14x14
ConvBNReLU(512, 512):add(nn.Dropout(0.4))
--ConvBNReLU(1024, 1024):add(nn.Dropout(0.4))
--ConvBNReLU(1024, 1024)
vgg:add(MaxPooling(2, 2, 2, 2):ceil())
-- Bx512x7x7
vgg:add(nn.View(512*7*7))
classifier = nn.Sequential()
classifier:add(nn.Linear(512*7*7, 4096))
classifier:add(nn.BatchNormalization(4096))
classifier:add(nn.ReLU(true))
classifier:add(nn.Dropout(0.5))
classifier:add(nn.Linear(4096, 7*7*(6)))
vgg:add(classifier)
-- check that we can propagate forward without errors
-- should get 2x(7*7*6) vector.
--print(vgg);
print(vgg:cuda():forward(torch.CudaTensor(2,1,448,448)))
return vgg