-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathclassifier_10.py
35 lines (30 loc) · 1.33 KB
/
classifier_10.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
from keras.models import Sequential
from classifier_base import BaseClassifier
from keras.layers import *
from config import *
class SmallClassifier(BaseClassifier):
def __init__(self, name='small', lr=1e-3, batch_size=BATCH_SIZE, weights_mode='loss', optimizer=None):
BaseClassifier.__init__(self,name, IM_SIZE_224,
lr, batch_size, weights_mode, optimizer)
def create_model(self):
model = Sequential()
model.add(Conv2D(16, 3, activation='relu', padding='same',
input_shape=(self.im_size, self.im_size, 3)))
model.add(MaxPooling2D())
model.add(BatchNormalization())
model.add(Conv2D(32, 3, activation='relu', padding='same'))
model.add(MaxPooling2D())
model.add(BatchNormalization())
model.add(Conv2D(32, 3, activation='relu', padding='same'))
model.add(MaxPooling2D())
model.add(Flatten())
model.add(BatchNormalization())
model.add(Dense(1024, activation='relu', name='fc1'))
model.add(BatchNormalization())
model.add(Dense(1024, activation='relu', name='fc2'))
model.add(BatchNormalization())
model.add(Dense(CLASSES, activation='softmax'))
return model
if __name__ == '__main__':
classifier = SmallClassifier(lr=1e-3)
classifier.train()