-
Notifications
You must be signed in to change notification settings - Fork 47
/
keras_model.py
72 lines (55 loc) · 1.91 KB
/
keras_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
@file keras_model.py
@brief Script for keras model definition
@author Toshiki Nakamura, Yuki Nikaido, and Yohei Kawaguchi (Hitachi Ltd.)
Copyright (C) 2020 Hitachi, Ltd. All right reserved.
"""
########################################################################
# import python-library
########################################################################
# from import
import keras.models
from keras.models import Model
from keras.layers import Input, Dense, BatchNormalization, Activation
########################################################################
# keras model
########################################################################
def get_model(inputDim):
"""
define the keras model
the model based on the simple dense auto encoder
(128*128*128*128*8*128*128*128*128)
"""
inputLayer = Input(shape=(inputDim,))
h = Dense(128)(inputLayer)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(8)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(128)(h)
h = BatchNormalization()(h)
h = Activation('relu')(h)
h = Dense(inputDim)(h)
return Model(inputs=inputLayer, outputs=h)
#########################################################################
def load_model(file_path):
return keras.models.load_model(file_path)