-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
28 lines (24 loc) · 848 Bytes
/
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
from keras.models import Sequential
from keras.models import *
from keras.layers import *
from keras.layers.embeddings import Embedding
def make_model():
"""Builds the LSTM, with 2 layers and reasonable drop out,
and binary cross entropy as the loss function
"""
model = Sequential()
model.add(Embedding(50000, 100, input_length=11))
#layer 1
model.add(LSTM(256, return_sequences=True))
model.add(Dropout(0.5))
model.add(BatchNormalization())
#layer 2
model.add(LSTM(128))
model.add(Dropout(0.5))
model.add(BatchNormalization())
model.add(Dense(1, activation='sigmoid'))
#Defines loss function and prediction metric
model.compile(loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
return model