[6ab127]: / create_rnn_model.py

Download this file

12 lines (9 with data), 414 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Embedding, LSTM, Dense
def create_rnn_model(input_shape, num_classes):
model = Sequential()
model.add(Embedding(input_dim=10000, output_dim=128, input_length=input_shape[1]))
model.add(LSTM(64))
model.add(Dense(128, activation='relu'))
model.add(Dense(num_classes, activation='softmax'))
return model