# Week 3 W1 Shape

I must be missing something… In the “initialize_parameters(n_x, n_h, n_y):” function, I set the dimensions of the W1 array to n_h, n_x, which were assigned to 4 and 5 in the “layer_sizes (X, Y)” function (W1 = np.random.randn(n_h, n_x) * 0.01). But when I run initialize_parameters, W1 comes back as a 4x2 array, which the expected answer shows as correct:

``````W1 = [[-0. -0.00056267]
[-0.02136196  0.01640271]
[-0.01793436 -0.00841747]
[ 0.00502881 -0.01245288]]
``````

Why isn’t W1 a 4x5 array? How did W1 change shape? I’m stuck, so any help would be appreciated!

Hi, I guess you are working on the Exercise 3, in that exercise there is a function which sets the values for `n_x`, `n_h` and `n_y`. Whatever comes after that needs to be consistent with those dimensions.

``````n_x, n_h, n_y = initialize_parameters_test_case()
``````

I would suggest you call that function and print out the values
Spoiler: they are not 5, 4, 2

1 Like

Haha! Thanks for the quick response and the spoiler, Alberto. Yes, I printed the array shapes. I expected that once the array shapes were defined in Exercise 2, that they would remain consistent throughout the assignment and not change via an external function in Exercises 3. The Planar data obviously needs to remain consistent, so I expected the same for the test exercises. I thought I was missing something about the theory, but I get it now :). (Although it still would make more sense IMO to set the proper array sizes in Exercise 2 and stay with them…). Anyway.

Thanks again!

You’re welcome, I’m glad you solved the issue.

You’re not the first student who get confused with the fact that some variables change between the different exercises… on the positive side, some students had also hardcoded some values in functions and that problem was identified with the change of the inputs

1 Like