-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
37 lines (34 loc) · 1.01 KB
/
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
# Model file
from imports import *
from preprocessing import network_params
from make_data import make
from keras.layers import BatchNormalization as BatchNorm
#Function to create lstm model for training
def lstm_model(inputs, total_classes):
model = Sequential()
model.add(LSTM(
512,
#input_shape=(inputs.shape[1], inputs.shape[2]),
input_shape=(inputs.shape[1], inputs.shape[2]),
recurrent_dropout=0.3,
return_sequences=True
))
model.add(LSTM(512, return_sequences=True, recurrent_dropout=0.3,))
model.add(LSTM(512))
model.add(BatchNorm())
model.add(Dropout(0.3))
model.add(Dense(256))
model.add(Activation('relu'))
model.add(BatchNorm())
model.add(Dropout(0.3))
model.add(Dense(total_classes))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
return model
#Testing purposes
if __name__ == "__main__":
notes = make()
arr = network_params(notes[0], notes[1], 100)
inputs = arr[0]
total_classes = notes[1]
model = lstm_model(inputs, total_classes)