# Week 3 Assignment Exercise 2

**URL:** <https://community.deeplearning.ai/t/week-3-assignment-exercise-2/202690>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [September 12, 2022, 5:31am UTC](https://community.deeplearning.ai/t/week-3-assignment-exercise-2/202690 "2022-09-12T05:31:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandesh\_Tyagi](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Sandesh\_Tyagi](https://community.deeplearning.ai/u/Sandesh_Tyagi)\
**Post date:** [September 12, 2022, 5:31am UTC](https://community.deeplearning.ai/t/week-3-assignment-exercise-2/202690/1 "2022-09-12T05:31:18Z")

</div>

In the compute cost function I ran this code below:

**[Moderator edit: solution code removed]**

And I am getting this error

ValueError: shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)

help me resolve this with a little explanation

---

<div class="post-metadata">

**Author:** ![kenb](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kenb/32/69_2.png) [@kenb](https://community.deeplearning.ai/u/kenb)\
**Post date:** [September 12, 2022, 11:29am UTC](https://community.deeplearning.ai/t/week-3-assignment-exercise-2/202690/2 "2022-09-12T11:29:01Z")

</div>

Hi, @Sandesh_Tyagi. In mathematical terms,The `ValueError` exception is telling you that two arrays that you are trying to apply [vector/matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication#:~:text=In%20mathematics%2C%20particularly%20in%20linear,rows%20in%20the%20second%20matrix.) (which the `np.dot` function will do) are not conformable to that operation.

For a valid expression, the inner product dimensions must of the two matrices must agree. For example, multiplying a (1, 3) by a (3, 1) would work, because 3 = 3. (On that we can all agree.) The result will be a (1, 1) – a scalar. Hint: One of the matrices must be transposed.

**Note:** It is against the honor code to post your solution code. However, you are encouraged to post an image of your traceback (i.e., the error log). Any code that incidentally shows up in that is fine.

---

<div class="post-metadata">

**Author:** ![Sandesh\_Tyagi](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Sandesh\_Tyagi](https://community.deeplearning.ai/u/Sandesh_Tyagi)\
**Post date:** [September 13, 2022, 11:39am UTC](https://community.deeplearning.ai/t/week-3-assignment-exercise-2/202690/3 "2022-09-13T11:39:41Z")

</div>

![Screenshot (1)](https://global.discourse-cdn.com/dlai/original/3X/d/3/d3e995a09d2092ad9a306ad582e13a4165d22bc8.png)

Please explain me this code …  
why we did np.random.seed explain the next two lines also
