NumPy allowed · plain Python earns 10 bonus points
Compute recurrent state transitions for sequence modeling in a classic Elman recurrent neural network.
Implement vanilla_rnn_step_forward(x, h_prev, Wxh, Whh, bh): for each batch sample i, compute the new hidden state h_next[i] = tanh(x[i] @ Wxh + h_prev[i] @ Whh + bh). Return h_next of shape (N, H) with all elements rounded to 4 decimal places.
vanilla_rnn_step_forward(x: list[list[float]], h_prev: list[list[float]], Wxh: list[list[float]], Whh: list[list[float]], bh: list[float]) -> list[list[float]]