-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
40 lines (32 loc) · 1.33 KB
/
model.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
from keras.models import Sequential
from keras.layers import Dense, Dropout, Conv2D, MaxPooling2D, Reshape, Flatten
def build_model(is_train):
inputshape = (4800,)
imgshape = (40, 40, 3)
kernel = (3, 3)
pooling = (2, 2)
model = Sequential()
# our input vector is flat, but Conv2D wants a 3d
# shaped tensor (width, height, depth), reshape it.
model.add( Reshape(imgshape, input_shape=inputshape) )
# add some convolutional filters
model.add( Conv2D(32, kernel, activation='relu') )
model.add( Conv2D(64, kernel, activation='relu') )
# downsample from the convolutional filters
model.add( MaxPooling2D(pool_size=pooling) )
# add some convolutional filters
model.add( Conv2D(128, kernel, activation='relu') )
model.add( Conv2D(256, kernel, activation='relu') )
# downsample from the convolutional filters
model.add( MaxPooling2D(pool_size=pooling) )
# flatten results for the next dense layer
model.add( Flatten() )
# this layer is gonna learn how to classify planes
# according to the inputs that the convolutional
# and dropout layers activate.
model.add( Dense(512, activation='relu') )
# avoid overfitting
model.add( Dropout(0.5) )
# the output layer
model.add( Dense(2, activation='softmax') )
return model