Can't code layer_sizes in Week 3 programming assignment

The fill-in-the-blanks for layer_sizes looks super-easy in Planar_data_classification_with_one_hidden_layer. In fact it looks obvious. But when I type the apparently needed values for n_x and so on, the test tells me I have the wrong values. I thought at first I had a simple misunderstanding, this function’s SO easy.

But there’s nothing I can do to make it pass. I tried changing the values I entered to match the error message’s claim about the expected values – but the expected values change when I change my n_x and so on. I’m absolutely baffled. Why would the expected values ever change?

lab id iixgqtvp

Hi, William. Your code should inherit the arguments in the layers_size(X, Y) function declaration. In this case, X and Y. As stated in the instructions to Exercise 2, the hidden layer size is “hard-coded” to 4. For the other two, you must reference X and Y.


Thank you, I see that I misunderstood what “reference” meant – I thought I was supposed to look at how X had been defined earlier (in the problem). If I’d read the provided function more closely I could have avoided my confusion by noticing that X and Y were parameters passed to the function (that happened to share the same name as the X and Y that were being discussed in the rest of the problem).