-
Notifications
You must be signed in to change notification settings - Fork 0
/
createModel.py
37 lines (27 loc) · 1021 Bytes
/
createModel.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
import converter
from tensorflow.keras import layers
from tensorflow.keras.models import Sequential
input_dim = 160
output_dim = 256
epochs=2500
batch_size=256
def createAndSaveModel(firstDenseDimension, hiddenDenseLayers, heightDenseLayer, file, x, y):
sequential_array = []
# input layer
sequential_array.append(layers.Dense(firstDenseDimension, activation='sigmoid', input_shape=(input_dim,)))
# hidden layers
for i in range(hiddenDenseLayers):
sequential_array.append(layers.Dense(heightDenseLayer, activation='relu'))
# output layer
sequential_array.append(layers.Dense(output_dim, activation='sigmoid'))
# create model
model = Sequential(sequential_array)
# compile model
model.compile(optimizer='adamax',
loss='binary_crossentropy'
)
model.summary()
# train model
model.fit(x, y, epochs=epochs, batch_size=batch_size)
# save model
model.save(file)