Bird
0
0

How do you correctly add an LSTM layer with 100 units in a Keras Sequential model for text input of shape (timesteps, features)?

easy📝 Syntax Q3 of 15
NLP - Sequence Models for NLP
How do you correctly add an LSTM layer with 100 units in a Keras Sequential model for text input of shape (timesteps, features)?
Amodel.add(LSTM(100, input_shape=(timesteps, features)))
Bmodel.add(LSTM(100, input_dim=timesteps, input_length=features))
Cmodel.add(LSTM(units=timesteps, input_shape=(100, features)))
Dmodel.add(LSTM(100, input_shape=(features, timesteps)))
Step-by-Step Solution
Solution:
  1. Step 1: Understand input_shape

    For LSTM, input_shape is (timesteps, features).
  2. Step 2: Correct syntax

    Use LSTM(units, input_shape=(timesteps, features)) in Keras Sequential.
  3. Final Answer:

    model.add(LSTM(100, input_shape=(timesteps, features))) -> Option A
  4. Quick Check:

    Check input_shape format [OK]
Quick Trick: LSTM input_shape = (timesteps, features) [OK]
Common Mistakes:
MISTAKES
  • Swapping timesteps and features in input_shape
  • Using input_dim or input_length incorrectly
  • Setting units to timesteps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes