Week 1 / Dinosaurs / optimize() is marked wrong by autograder

Hi!

The autograder fails me with the following in the optimize function:

Code Cell UNQ_C3: Unexpected error (KeyError('da_next')) occurred during function check. We expected function `optimize` to return Test 3 failed. Please check that this function is defined properly.

I assume this is due to an extra parameter in utils.py as the actual gradients dictionary does not have a da_next key. The key is mentioned in the backprop:

def rnn_step_backward(dy, gradients, parameters, x, a, a_prev):

  gradients['dWya'] += np.dot(dy, a.T)
  gradients['dby'] += dy
  da = np.dot(parameters['Wya'].T, dy) + gradients['da_next'] # backprop into h
  daraw = (1 - a * a) * da # backprop through tanh nonlinearity
  gradients['db'] += daraw
  gradients['dWax'] += np.dot(daraw, x.T)
  gradients['dWaa'] += np.dot(daraw, a_prev.T)
  gradients['da_next'] = np.dot(parameters['Waa'].T, daraw)
  return gradients

Hi,

Do you follow the instructions to use provided api:

gradients['da_next'] is initialized in function rnn_backward.

1 Like

@edwardyu I checked it again. I call the function as described and also found the initialization now. Any other idea, why the auto grader complains? This seems to be something that is out of my scope for that task.

Did you use the clip function defined earlier in the notebook?