Cannot compile code

I have tried to submit my week 3 lab coding assignment for over a week now, but it still says that it cannot compile code from the notebook. I have restarted the kernel on multiple occasions. It says all test are passed, except for the following test:

Actual values are not checked here in the unit tests (due to random initialization).

I am not sure what else to do.

1 Like

It appears there is a mistake in your initialize_parameters() function. The shape of W is not correct, that’s why it hits that assert.

I’m not a mentor for that course, so I don’t have access to the materials.

1 Like

That’s weird because the size of W isn’t anything that I changed.

1 Like

As I said, it’s not my course, but I have to wonder why the function has an assert that checks if W.shape is (n_y,1), when there are parameters for both n_x and n_y.

1 Like

Hi @Morgan_Fitzgerald.

The bias value should be a vector of shape (n_y, 1). Let me know if there’s still an error after your revision.

1 Like

@jonrico, it looks to me like the assert is being thrown by the line 16 “W.shape” code.

1 Like

Hi @TMosh. That’s also what I noticed which is a bit weird. That’s why I asked him to remove all code mistakes first then let me know if there’s still an error message.


@jonrico Hi Johnathan, thanks for getting back to me. I wasn’t sure if you meant that n_y, 1 should be the definition of b or just the shape, but I tried both with n_y and still have the same error.

    ### START CODE HERE ### (~ 2 lines of code)
    W = np.random.randn(n_y, n_x) * 0.01
    b = np.zeros((n_y, 1))
    ### END CODE HERE ###
    assert (W.shape == (n_y, 1))
    assert (b.shape == (n_y, 1))

Thank you.


Can you tell me the title of the exercise? For example, “Classification with Perceptron” or “Neural Network with Two Layers”

1 Like

Hi, yes. It is - Programming Assignment: Single Perceptron Neural Networks for Linear Regression.

This is under section 2.2 - Initialize the Model’s Parameters - Exercise 3. Implement the function initialize_parameters()

1 Like

I see. The error could be from the previous Exercises. Can you download your .ipynb notebook and send it to me privately?

1 Like

Hi @Morgan_Fitzgerald

Let me know if you need help downloading your .ipynb notebook and sending it privately.

1 Like

Just sent! Thank you

1 Like


I just noticed that you might have accidentally edited the assert line:

assert (W.shape == (n_y, 1))

This is not part of the editable code for grading. So in general, you should avoid editing codes outside the “START CODE HERE” and “END CODE HERE” to avoid unnecessary errors.

The original assert line is this:

assert (W.shape == (n_y, n_x))

1 Like