# Cannot compile code

**URL:** <https://community.deeplearning.ai/t/cannot-compile-code/324009>\
**Category:** Linear Algebra for Machine Learning and Data Sc...\
**Tags:** week-module-3\
**Created:** [May 3, 2023, 9:18pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009 "2023-05-03T21:18:10Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morgan\_Fitzgerald](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Morgan\_Fitzgerald](https://community.deeplearning.ai/u/Morgan_Fitzgerald)\
**Post date:** [May 3, 2023, 9:18pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/1 "2023-05-03T21:18:10Z")

</div>

Hello,  
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:

```auto
Note: 
Actual values are not checked here in the unit tests (due to random initialization).
w3_unittest.test_initialize_parameters(initialize_parameters)

```

 ![Screenshot 2023-05-03 at 2.16.41 PM](https://global.discourse-cdn.com/dlai/original/3X/2/c/2c18bc429432def7027c5591eb10a3f6f63d58c6.png)

I am not sure what else to do.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [May 3, 2023, 10:22pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/2 "2023-05-03T22:22:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Morgan\_Fitzgerald](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Morgan\_Fitzgerald](https://community.deeplearning.ai/u/Morgan_Fitzgerald)\
**Post date:** [May 3, 2023, 10:45pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/3 "2023-05-03T22:45:29Z")

</div>

![Screenshot 2023-05-03 at 3.45.01 PM](https://global.discourse-cdn.com/dlai/original/3X/c/b/cbf15f13a9d1345a17f97ef8d189111656058a9a.png)

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

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [May 3, 2023, 11:03pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/4 "2023-05-03T23:03:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 4, 2023, 12:17am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/5 "2023-05-04T00:17:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [May 4, 2023, 12:55am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/6 "2023-05-04T00:55:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 4, 2023, 1:20am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/7 "2023-05-04T01:20:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Morgan\_Fitzgerald](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Morgan\_Fitzgerald](https://community.deeplearning.ai/u/Morgan_Fitzgerald)\
**Post date:** [May 4, 2023, 2:11pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/8 "2023-05-04T14:11:18Z")

</div>

@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.

```auto
    ### 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.

 ![Screenshot 2023-05-04 at 7.16.16 AM](https://global.discourse-cdn.com/dlai/original/3X/e/b/eb490cb751b05e1b442bdbccc250787682a12948.png)

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 4, 2023, 11:12pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/10 "2023-05-04T23:12:42Z")

</div>

Hi.

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

---

<div class="post-metadata">

**Author:** ![Morgan\_Fitzgerald](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Morgan\_Fitzgerald](https://community.deeplearning.ai/u/Morgan_Fitzgerald)\
**Post date:** [May 5, 2023, 12:06am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/11 "2023-05-05T00:06:07Z")

</div>

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()`

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 5, 2023, 12:11am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/12 "2023-05-05T00:11:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 7, 2023, 2:40pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/13 "2023-05-07T14:40:16Z")

</div>

Hi @Morgan_Fitzgerald

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

---

<div class="post-metadata">

**Author:** ![Morgan\_Fitzgerald](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Morgan\_Fitzgerald](https://community.deeplearning.ai/u/Morgan_Fitzgerald)\
**Post date:** [May 7, 2023, 5:39pm UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/14 "2023-05-07T17:39:25Z")

</div>

Just sent! Thank you

---

<div class="post-metadata">

**Author:** ![jonrico](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jonrico/32/44347_2.png) [@jonrico](https://community.deeplearning.ai/u/jonrico)\
**Post date:** [May 8, 2023, 12:04am UTC](https://community.deeplearning.ai/t/cannot-compile-code/324009/15 "2023-05-08T00:04:10Z")

</div>

Thanks!

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))
