Week 3 - Prog. Assignment - Error in backward_propagation()

Hi ,

Expected output for this function -
dW1 = [[ 0.00301023 -0.00747267]
[ 0.00257967 -0.00641287]
[-0.00156892 0.003893 ]
[-0.00652037 0.01618243]]

Values for W1 , on running the code-
dW1 = [[ 0.00301023 -0.00747267]
[ 0.00257968 -0.00641288]
[-0.00156892 0.003893 ]
[-0.00652037 0.01618243]]

The elements dW1[2,1] & dW1[2,2] ( marked in bold here ) ,differ in the order of 10^-8.
The backward_propagation_test(backward_propagation) fails with assertion ‘incorrect values for dW1’

a) What degree of accuracy is required for the model ?
8) I cannot figure out , why i get this difference

Please help
Thanks , Poulomi

The notebook relies on np.testing.assert_array_almost_equal to check for validity of the result. The default decimal check is for upto 6 places. So, you’re good to go.

Are you executing this notebook on coursera environment?

There are two tests actually.
The first test is a kind of “open” test.

parameters, cache, t_X, t_Y = backward_propagation_test_case()
grads = backward_propagation(parameters, cache, t_X, t_Y)

All values printed are the result of this open test. Actually, no values are checked. :slight_smile: Just a check by your eyes.

Then, a hidden test starts with this.


It is a hidden, but, if you see “public_test.py” in the same directly, you see what kind of tests are done. In it, there are “type check”, “shape check” and “value check” for dw1, db1, dw2, and db2.
Your error message comes from this.

This hidden test uses different size of X, Y, parameters and cache. You need to take a look at your implementation with this hidden test.