Bird
0
0

When building an LSTM model to classify movie reviews of varying lengths, which preprocessing technique best handles input sequences?

hard📝 Application Q8 of 15
NLP - Sequence Models for NLP
When building an LSTM model to classify movie reviews of varying lengths, which preprocessing technique best handles input sequences?
AFeed raw text directly into the LSTM without preprocessing
BUse only the first 10 words of each review without padding
CConvert each review into a fixed-size bag-of-words vector
DPad or truncate all sequences to a fixed length before feeding into the LSTM
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable-length input

    LSTMs require fixed input shapes per batch, so sequences must be uniform length.
  2. Step 2: Padding/truncation

    Padding shorter sequences and truncating longer ones standardizes input length.
  3. Step 3: Other options

    Using only first 10 words loses info; bag-of-words loses sequence order; raw text is invalid input.
  4. Final Answer:

    Pad or truncate all sequences to a fixed length before feeding into the LSTM -> Option D
  5. Quick Check:

    Uniform sequence length needed [OK]
Quick Trick: Pad/truncate sequences for uniform length [OK]
Common Mistakes:
MISTAKES
  • Ignoring sequence length variability
  • Using bag-of-words for sequence models
  • Feeding raw text without tokenization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes