RNN & LSTM interview question

Deep LearningRNN & LSTMbasic

In a vanilla recurrent neural network, what is the hidden state?

  1. AA fixed vector learned once during training and reused unchanged at every time step of every input sequence.
  2. BThe set of recurrent weight matrices, which are overwritten with new values at each time step of the forward pass.
  3. CA vector recomputed at each time step from the current input and the previous hidden state, summarizing the past.
  4. DThe output of the final time step only, which is computed after the entire sequence has been read in one go.
Show the answer and explanation

Correct answer: C, A vector recomputed at each time step from the current input and the previous hidden state, summarizing the past.

Explanation RNN & LSTM

The hidden state hₜ is the RNN's running memory. At each step it is recomputed from the current input and the previous hidden state, for example hₜ = tanh(Wₓₕ xₜ + Wₕₕ hₜ₋₁ + b). It therefore carries a summary of everything the network has read so far, and it can feed an output layer at every step.

Why the other descriptions are wrong:

  • A vector that never changes could not carry information about the sequence; only the initial state h₀ is a fixed (often zero) vector.
  • The weight matrices are shared across all time steps and are not changed by the forward pass; they change only when the optimizer updates them.
  • A hidden state exists at every step, not just the last one. Many-to-one tasks use only the final state, but the earlier ones are still computed.

Interview tip: write the recurrence hₜ = f(xₜ, hₜ₋₁) and stress weight sharing across time; that is what lets one RNN handle sequences of any length.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Deep Learning questions

  1. What is the core idea of an attention mechanism in a neural network?
  2. Which statement best defines transfer learning?
  3. Two system outputs are scored against a single reference in the table. Which interpretation of the scores is correct?
  4. A telecom's search-box autocomplete uses a bigram language model with add-one (Laplace) smoothing, P(w prev) = (c(prev, w) + 1) / (c(prev) + V). The table…
  5. The table shows how two tokenizers split the same text. What do the ## and Ġ markers mean?