0
0
NLPml~20 mins

RNN for text classification in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
RNN Text Classifier Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Model Choice
intermediate
2:00remaining
Choosing the right RNN layer for text classification

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?

AUse a Conv1D layer because convolution is better for sequence data than RNNs.
BUse a Dense layer directly on the input sequences without any recurrent layers.
CUse a MaxPooling layer to reduce sequence length before classification.
DUse a SimpleRNN layer because it is the most basic recurrent layer and captures sequence order.
Attempts:
2 left
💡 Hint

Think about which layer type is designed to handle sequences step-by-step.

Predict Output
intermediate
2:00remaining
Output shape of RNN layer in text classification model

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?

A(None, 32)
B(None, 100, 32)
C(None, 64)
D(None, 1)
Attempts:
2 left
💡 Hint

SimpleRNN returns the last output by default, not the full sequence.

Hyperparameter
advanced
2:00remaining
Choosing the right sequence length for RNN input

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?

ASet the sequence length to a fixed value like 100, truncating longer reviews and padding shorter ones.
BSet the sequence length to the maximum review length in the dataset to keep all information.
CSet the sequence length to the average review length without padding or truncation.
DDo not fix sequence length; feed variable-length sequences directly to the RNN.
Attempts:
2 left
💡 Hint

Think about model input requirements and efficiency.

Metrics
advanced
2:00remaining
Interpreting training metrics for RNN text classifier

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?

AThe model is performing well with high accuracy and low loss.
BThe model has perfect predictions on the validation set.
CThe model is underfitting and not learning enough from the data.
DThe model is overfitting the training data.
Attempts:
2 left
💡 Hint

Consider what accuracy and loss values mean for classification.

🔧 Debug
expert
2:00remaining
Debugging vanishing gradient in RNN training

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?

AThe dataset is too large, causing slow training.
BThe model suffers from vanishing gradients due to the SimpleRNN architecture.
CThe optimizer learning rate is too high, causing divergence.
DThe batch size is too small, causing unstable updates.
Attempts:
2 left
💡 Hint

Think about common problems with SimpleRNN layers in deep sequence models.