Hi,
I initialized the Adam parameters and gradients correctly according to the test in exercise 5. However, when trying to run the model using Adam, I get a KeyError for ‘dW3’. I am not quite sure what is causing this issue. Both the parameters and gradients are initialised as 0 (np.zeros()).
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-19-2ae185cb4f42> in <module>
1 # train 3-layer model
2 layers_dims = [train_X.shape[0], 5, 2, 1]
----> 3 parameters = model(train_X, train_Y, layers_dims, optimizer = "adam")
4
5 # Predict
<ipython-input-16-620ef2b96663> in model(X, Y, layers_dims, optimizer, learning_rate, mini_batch_size, beta, beta1, beta2, epsilon, num_epochs, print_cost)
36 v = initialize_velocity(parameters)
37 elif optimizer == "adam":
---> 38 v, s = initialize_adam(parameters)
39
40 # Optimization loop
<ipython-input-11-63378fbfde7f> in initialize_adam(parameters)
36 v["dW" + str(l)] = <removed to avoid sharing answers>
37 v["db" + str(l)] = <removed to avoid sharing answers>
---> 38 s["dW" + str(l)] = <removed to avoid sharing answers>
39 s["db" + str(l)] = <removed to avoid sharing answers>
40 # YOUR CODE ENDS HERE
KeyError: 'dW3'
For context, all previous tests passed with other models initialised similarly.
Any help is much appreciated!
Thanks!