February 2018
Beginner to intermediate
258 pages
5h 47m
English
Bidirectional LSTM seemed to be a good idea, right? What about a simpler network architecture?
Instead of a bidirectional LSTM, we can consider a simple LSTM. To do this, we can replace the preceding model (after doing the same preprocessing; that is, feeding the data in the same format) with a simple LSTM:
model <- keras_model_sequential()model %>% layer_embedding(input_dim = length(vocab), output_dim = 128, input_length = 100) %>% layer_lstm(units = 64, dropout = 0.2, recurrent_dropout = 0.2) %>% layer_dense(units = 1, activation = 'sigmoid') model %>% compile( loss = "binary_crossentropy", optimizer = "adam",
metrics = "accuracy")
After training, we get the following results:
Read now
Unlock full access