Why input neuron is 5?


As in the screenshot - shape of x is calculated above, in which the # of rows is 2… It makes sense since each training data contains a pair of location values (x,y); Why here X.shape[0] = 5 later on in this problem? What are the 5 properties? Thanks…

Hi, this one is referring to t_X which is the output of the layer_sizes_test_case. You can print out t_X.shape to check it.

1 Like

RIght! It’s just a test case for the layer_sizes function. There’s no reason that the number of features has to be equal to the number of features in the “real” data.

For people like me who are not able to understand what dear instructors @albertovilla and @paulinpaloalto are saying, here is the explanation in plain English.

In exercise 2 we are asked to define a function.
When we define a function, we use dummy variables as the arguments of the function - X and Y in our case.
Inside the function body anything - including the definition of n_x, n_y and n_h - must be written in terms of the dummy variables X and Y, not in terms of the global variables shape\_X and shape\_Y.

It’s a very silly mistake. But once you make it, you can’t detect it, especially if you are doing the assignment in the evening after a full very hard working day.

Ivan

All the functions we are writing here are supposed to be “self-contained” meaning that they do not reference global variables within the local scope of the function. If you are not familiar with the way “scope” works, you might want to put this course on “pause” and take an introductory python course first. But the way scoping works in python is very standard and common to just about any procedural programming language. You should only reference the formal parameters of the function and any local variables that your code creates within the scope of the function.

1 Like

Thank you! This solves my problem. The global variables X_shape and Y_shape in exercise #4 is indeed quite confusing.