-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_model.py
More file actions
29 lines (18 loc) · 781 Bytes
/
get_model.py
File metadata and controls
29 lines (18 loc) · 781 Bytes
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
from tensorflow.keras.applications.xception import Xception
from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2
from tensorflow.keras.layers import Dense
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import Adam
base_model = MobileNetV2(include_top=False, pooling="max")
for index, layer in enumerate(base_model.layers):
if index == len(base_model.layers) - 15:
break
layer.trainable = False
x = Dense(256, activation='relu')(base_model.outputs[0])
output = Dense(1, activation='softmax')(x)
model = Model(inputs=base_model.inputs, outputs=[output])
model.compile(loss='binary_crossentropy',
optimizer=Adam(0.001),
metrics=["accuracy"])
model.save('models/Mobile.h5')
print("Done!")