Data Science & ML

RNN & Sequences

RNN, LSTM, GRU, vanishing gradient, time series, forecasting, sequence-to-sequence

22 interview questions·
Senior
1

What is the main characteristic that distinguishes an RNN from a classical feedforward neural network?

Answer

An RNN has recurrent connections that maintain a hidden state which evolves over time. This hidden state acts as a memory capturing information from previous inputs in the sequence. Unlike feedforward networks where each input is processed independently, RNNs can model temporal dependencies between sequence elements.

2

How is the hidden state h_t calculated in a simple RNN (vanilla RNN) at each time step?

Answer

In a vanilla RNN, the hidden state h_t is calculated by applying an activation function (usually tanh) to the linear combination of the current input x_t weighted by W_xh and the previous hidden state h_{t-1} weighted by W_hh, plus a bias. This formula allows the network to combine new information with memory from previous time steps.

3

What is the main vanishing gradient problem in RNNs and when does it occur?

Answer

Vanishing gradient occurs during backpropagation through time (BPTT) when gradients are multiplied many times by values less than 1. Over long sequences, these gradients become exponentially small, preventing the network from learning long-term dependencies. The weights of early temporal layers are barely updated.

4

What are the three gates that compose an LSTM cell and what is their respective role?

5

How does LSTM solve the vanishing gradient problem compared to vanilla RNN?

+19 interview questions

Master Data Science & ML for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free