-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
63 lines (47 loc) · 1.62 KB
/
models.py
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
from keras.layers import Dense, Dropout, Conv2D, Input, MaxPool2D, Flatten
from keras.models import Model
from keras.layers.normalization import BatchNormalization
from keras.layers import ELU
def proposed_model(input_h=128, input_w=128):
input_shape = (input_h, input_w, 3)
nb_classes = 8
inputs = Input(input_shape)
# layer 1
x = Conv2D(64, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(inputs)
x = ELU()(x)
x = BatchNormalization()(x)
# layer 2
x = Conv2D(64, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(x)
x = ELU()(x)
x = BatchNormalization()(x)
# layer3
x = MaxPool2D(pool_size=(2, 2), strides=(2, 2))(x)
# layer4
x = Conv2D(128, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(x)
x = ELU()(x)
x = BatchNormalization()(x)
# layer5
x = Conv2D(128, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(x)
x = ELU()(x)
x = BatchNormalization()(x)
# layer6
x = MaxPool2D(pool_size=(2, 2), strides=(2, 2))(x)
# layer7
x = Conv2D(256, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(x)
x = ELU()(x)
x = BatchNormalization()(x)
# layer 8
x = Conv2D(256, (3, 3), strides=(1, 1), kernel_initializer='glorot_uniform')(x)
x = ELU()(x)
x = BatchNormalization()(x)
# layer 9
x = MaxPool2D(pool_size=(2, 2), strides=(2, 2))(x)
x = Flatten()(x)
# layer 10
x = Dense(2048)(x)
x = ELU()(x)
x = BatchNormalization()(x)
x = Dropout(0.5)(x)
x = Dense(nb_classes, activation='softmax')(x)
model = Model(inputs, x)
return model