In this section, we will develop the architecture for the recurrent neural network and compile it. Let's look at the following code:
# Model architecture
model <- keras_model_sequential()
model %>%
layer_embedding(input_dim = 500, output_dim = 32) %>%
layer_simple_rnn(units = 8) %>%
layer_dense(units = 1, activation = "sigmoid")
We start by initializing the model using the keras_model_sequential function. Then, we add embedding and simple recurrent neural network (RNN) layers. For the embedding layer, we specify input_dim to be 500, which is the same as the number of most frequent words that we had specified earlier. The next layer is a simple RNN layer, with the number of hidden units specified as 8.
Note that the default activation function for the layer_simple_rnn layer is...