The single-step vanilla-RNN implementation in the starter code has two bugs that cause hidden activations and their gradients to collapse during BPTT through long sequences. Find and fix them.
Signature: def rnn_step_buggy(x, h_prev, Wx, Wh, b)
x: input vector of shape (input_size,)h_prev: previous hidden state of shape (hidden_size,)Wx: input projection (hidden_size, input_size)Wh: recurrent projection (hidden_size, hidden_size)b: bias (hidden_size,)h of shape (hidden_size,)The function should compute one canonical Elman-style RNN step — nothing more, nothing less. If you're not sure what "canonical" looks like here, sketch the math for a single step and check the buggy code against it line by line.
Asked at
import numpy as np
def rnn_step_buggy(...):
pass
Premium problem
Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.
Already premium?