Size of layers in Course 1 Week3 Planar Data Class program assignment

I think I’m going mad. The question in Exercise 2 (week 3 - Deep Learning specialisation course 1) is to produce ‘n_x’ as the size of the input layer and the expected output is 5 (this is given to us). I cannot see how 5 is arrived at. The expected output for Shape of X is 2, 400; the diagram shows the input layer as x1 and x2; the following exercise initialises W1 into a matrix whose expected output has shape 4,2 (again, this is given to us). How is the size of the input layer 5? I must have missed something in the videos about size not being the same as the vector size for x/number of rows for X

1 Like

Dear @wayneh in assume the input_size of the Excercise 2 has to do with the data used to validate the excercise itself and has to do with the matrix t_X returned by the function:

t_X, t_Y = layer_sizes_test_case()

Therefore the input vecter with n_x equal to 5 is user only to grade layer_sizes funtion.
Hope this helps :slight_smile:

Thank you for your answer, but I still do not understand. Working sequentially through the exercises the graded exercise asks for n_x and n_y without any reference to t_X or layer_sizes_test_case(). There is a hint that says use the shape of X and Y - I don’t see anything that results in 5 in the shape of X and Y.
[combining messages into one]
I hope you do not mind if I provide this feedback: I think there should be some guidance within the text that points the student to use t_X and t_Y - the guidance says use X and Y as arguments, but nowhere in the previous text or class videos is there any reference to these objects or this approach - there is no explanation of what t_X and t_Y are - I still don’t know what they are. But also, if I use t_X and t_Y, then I am using them before they are assigned value by layer_sizes_test_case(). I hope that all makes sense.
… and now I’m super confused, because in the next exercise n_x is used to set the dimensions of W1, and the expected output for W1 has dimension [4,2], which means that n_x is 2 not 5 :thinking:

All the code we are writing here is supposed to be “general” in the sense that we don’t hard-code any of the dimensions. That also means you shouldn’t assume that n_x is any specific value. Yes, the actual training data that we use to draw the pretty pictures has 2 features, but the code like the initialize routine should still work if n_x is 5 or 42 or some other value. The test case with n_x = 5 and n_y = 2 is just a “unit test” for that particular subroutine.

1 Like

ok, and always thanks for the reply … but I still think (please take this as student feedback) that from a didactic pov the guidance around the stated objective of the code required in exercise 2 (" n_x = size of the input layer" - this is the task set in E2) does not correspond with what is actually expected (“n_x = size of a different object that is not the input layer and which has not so far been mentioned”). All this said with the positive intention of continual improvement and openness and best wishes. :slightly_smiling_face:

3 days on, I have grown older (not easy at my age), wiser (very easy), become a better programmer, and realise the errors of my ways. Mea Culpa. “feedback” withdrawn, it is a well-set problem :blush: