Bird
0
0

What will be the output shape of the following LSTM layer?

medium📝 Predict Output Q5 of 15
NLP - Sequence Models for NLP
What will be the output shape of the following LSTM layer?
model.add(LSTM(32, input_shape=(15, 20), return_sequences=True))
A(15, 32)
B(None, 32)
C(None, 15, 32)
D(None, 20, 32)
Step-by-Step Solution
Solution:
  1. Step 1: Understand return_sequences=True effect

    When return_sequences=True, LSTM outputs a sequence for each timestep, shape (batch_size, timesteps, units).
  2. Step 2: Apply to given parameters

    Input timesteps=15, units=32, batch size unknown (None), so output shape is (None, 15, 32).
  3. Final Answer:

    (None, 15, 32) -> Option C
  4. Quick Check:

    return_sequences=True output shape = (batch, timesteps, units) [OK]
Quick Trick: return_sequences=True keeps time steps in output [OK]
Common Mistakes:
MISTAKES
  • Ignoring return_sequences parameter
  • Mixing up features and timesteps
  • Omitting batch size dimension

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes