This repository has been archived by the owner on Sep 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
48 lines (40 loc) · 1.87 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
from keras.applications.mobilenetv2 import MobileNetV2
from keras_monad import KerasMonad
from config import *
class Model:
def __init__(self):
pass
def build_alexnet(self):
model = KerasMonad()
alexnet = model \
.input(conf.dims) \
.conv2d(48, 11, strides=(2, 3)) \
.max_pooling2d(3, strides=(1, 2)) \
.normalize() \
.conv2d(128, 5, strides=(2, 3)) \
.max_pooling2d(3, strides=(2, 1)) \
.normalize() \
.conv2d(192, 3, strides=(1, 2)) \
.conv2d(192, 3, strides=(1, 1)) \
.conv2d(128, 3, strides=(1, 1)) \
.max_pooling2d(3, strides=(1, 2)) \
.normalize() \
.flatten() \
.dense(256) \
.dropout(0.5) \
.dense(256) \
.dropout(0.5) \
.dense(conf.num_classes, activation='softmax')
return alexnet.build()
def build_mobilenetv2(self):
base = MobileNetV2(weights=None,
input_shape=conf.dims,
include_top=False,
alpha=0.35,
depth_multiplier=0.5)
model = KerasMonad(base.output)
mobilenetv2 = model \
.global_avg_pooling2d() \
.dense(1024) \
.dense(conf.num_classes, activation='softmax')
return mobilenetv2.build()