NumPy allowed · plain Python earns 10 bonus points
Regulate sequence memory and overcome vanishing gradients using gated LSTM memory cells.
Implement lstm_cell_forward(...): compute combined gate pre-activations raw = x @ W_x + h_prev @ W_h + b of length 4 * H. Split into input gate i = sigmoid(raw[0:H]), forget gate f = sigmoid(raw[H:2H]), candidate cell g = tanh(raw[2H:3H]), and output gate o = sigmoid(raw[3H:4H]). Update cell state c_next = f * c_prev + i * g, and hidden state h_next = o * tanh(c_next). Return {'h_next': h_next, 'c_next': c_next} with elements rounded to 4 decimal places.
lstm_cell_forward(x: list[list[float]], h_prev: list[list[float]], c_prev: list[list[float]], W_x: list[list[float]], W_h: list[list[float]], b: list[float]) -> dict