The code for compiling the model is as follows:
# Compile model
model %>% compile(optimizer = "rmsprop",
loss = "binary_crossentropy",
metrics = c("acc"))
We compile the model with the rmsprop optimizer, which is recommended for recurrent neural networks. We make use of binary_crossentropy as the loss function due to a binary type of response since movie reviews are either positive or negative. Finally, for metrics, we have specified accuracy.
In the next section, we will use this architecture to develop a movie review sentiment classification model that uses recurrent neural networks.