You want to build a simple recurrent neural network for classifying movie reviews as positive or negative. Which RNN layer is best suited to capture the sequence information while keeping the model simple?
Think about which layer type is designed to handle sequences step-by-step.
SimpleRNN is a recurrent layer designed to process sequences step-by-step, capturing order and dependencies. Conv1D and MaxPooling are not recurrent and Dense layers alone do not handle sequence order.
Consider the following Keras model snippet for text classification:
model = Sequential() model.add(Embedding(input_dim=10000, output_dim=64, input_length=100)) model.add(SimpleRNN(32)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) print(model.layers[1].output_shape)
What will be printed as the output shape?
SimpleRNN returns the last output by default, not the full sequence.
The SimpleRNN layer with 32 units outputs a vector of size 32 for each input sample. The batch size is None (unspecified), so the output shape is (None, 32).
You are training an RNN for text classification on movie reviews. Your dataset has reviews of varying lengths, but you must fix the input length for the model. What is the best approach to set the sequence length?
Think about model input requirements and efficiency.
RNN models require fixed input lengths. Setting a fixed length like 100 and padding/truncating sequences is standard practice to balance information retention and computational efficiency.
After training an RNN text classification model, you observe the following metrics on the validation set:
- Loss: 0.65
- Accuracy: 0.60
What does this tell you about the model's performance?
Consider what accuracy and loss values mean for classification.
An accuracy of 60% and loss of 0.65 on validation is low performance, indicating the model is underfitting and not capturing patterns well.
You train a SimpleRNN model for text classification but notice the training loss barely decreases after many epochs. Which of the following is the most likely cause?
Think about common problems with SimpleRNN layers in deep sequence models.
SimpleRNN layers often suffer from vanishing gradients, making it hard to learn long-range dependencies, causing training loss to stagnate.