Week 3 exercise 2

In the exercise 2 it is said to hard code the hidden layer size to 4, but when giving n_h =4 , it gives back the following error:

AssertionError: Not all tests were passed for layer_sizes. Check your equations and avoid using global variables inside the function.

Could any one help me with this

LikeReply 1Unfollow this post


Hi @Rvi, and welcome! The layer_sizes function, a function of the data in X and Y, contains three lines of code for you to fill in. The n_h = ... line is the only one which is not inferred from the function arguments (X and Y)–it can’t be. That is where the “hard-coding” must take place. The other two, n_x and n_y, are inferred from the arguments using numpy’s shape attribute. If you are unfamiliar with using that, there is an explanatory hint in Exercise 1. Hope this helps!