# C1W4\_Assignment - Exercise 3

**URL:** <https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697>\
**Category:** Linear Algebra for Machine Learning and Data Sc...\
**Tags:** week-module-4\
**Created:** [July 13, 2024, 8:16pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697 "2024-07-13T20:16:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![renan\_leme](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@renan\_leme](https://community.deeplearning.ai/u/renan_leme)\
**Post date:** [July 13, 2024, 8:16pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/1 "2024-07-13T20:16:40Z")

</div>

I passed all tests, I tested the shape of all matrices and everything is apparently ok. But when I submitted my notebook Coursera graded me with a 0 score in exercise 3. The Coursera message is “There was a problem grading your submission. Details: cannot reshape array of size 220 into shape (55,4096)”, but I have checked the shapes os the matrices and all of them are correct and All tests passed.

Can someone help me?

_{moderator edit - solution code removed}_

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 13, 2024, 8:27pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/2 "2024-07-13T20:27:34Z")

</div>

You are hard-coding the dimensions to be 55 and 4096. What if the grader uses a test case with a different size?

The point is that we should always strive to write code that is “general”, meaning that it works for inputs of any possible size and shape. Unless they specifically tell you to hard-code dimensions, it is always a mistake to do that.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 13, 2024, 8:39pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/3 "2024-07-13T20:39:49Z")

</div>

Note that it is easy to write this code without mentioning any of the dimensions. Instead of using the `np.repeat` function to duplicate the mean vector, just use numpy “broadcasting”. You can directly subtract the mean vector from the original matrix and it works fine.

---

<div class="post-metadata">

**Author:** ![renan\_leme](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@renan\_leme](https://community.deeplearning.ai/u/renan_leme)\
**Post date:** [July 13, 2024, 10:56pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/4 "2024-07-13T22:56:02Z")

</div>

_{moderator edit - solution code removed}_

 ![2](https://global.discourse-cdn.com/dlai/original/3X/4/7/47a5ecb0d40459a33efa5e12da3a7434790e12e2.jpeg)  
Hi @paulinpaloalto, I agree with you. I have changed my code to become more generic than before, but it still grading zero. Please, see the two attached imagens.

---

<div class="post-metadata">

**Author:** ![renan\_leme](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@renan\_leme](https://community.deeplearning.ai/u/renan_leme)\
**Post date:** [July 13, 2024, 10:57pm UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/5 "2024-07-13T22:57:05Z")

</div>

By the way, I have checked all matrix shapes and they are all correct.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 14, 2024, 12:09am UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/6 "2024-07-14T00:09:41Z")

</div>

Are you sure you hit “Save” before you did the “Submit”? One possibility is that the grader is seeing an older version of your code. I don’t see 4096 in your current code anywhere.

---

<div class="post-metadata">

**Author:** ![renan\_leme](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@renan\_leme](https://community.deeplearning.ai/u/renan_leme)\
**Post date:** [July 14, 2024, 12:14am UTC](https://community.deeplearning.ai/t/c1w4-assignment-exercise-3/662697/7 "2024-07-14T00:14:59Z")

</div>

I hadn’t saved the file!!!

Thanks, now I have 100%!
