-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodel.py
More file actions
23 lines (18 loc) · 841 Bytes
/
Copy pathmodel.py
File metadata and controls
23 lines (18 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from keras.applications.vgg19 import VGG19
from keras.models import Sequential,Model,load_model
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D, GlobalAveragePooling2D
from keras.optimizers import SGD, Adam, Nadam
def model(img_height, img_width, num_classes, lr):
base_model = VGG19(weights=None, include_top=False, input_shape=(img_height, img_width, 1))
x = base_model.output
x = Flatten()(x)
x = Dense(4096, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(4096, activation='relu')(x)
x = Dropout(0.5)(x)
predictions = Dense(num_classes, activation='sigmoid')(x)
model = Model(inputs=base_model.input, outputs=predictions)
adam = Adam(lr=lr)
model.compile(optimizer=adam, loss='binary_crossentropy', metrics=['binary_accuracy'])
model.summary()
return model