# Wrong definition of E in C2\_W2\_Assignment

**URL:** <https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943>\
**Category:** Calculus for Machine Learning and Data Science\
**Tags:** week-module-2\
**Created:** [February 10, 2023, 4:10pm UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943 "2023-02-10T16:10:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![toontalk](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/toontalk/32/10446_2.png) [@toontalk](https://community.deeplearning.ai/u/toontalk)\
**Post date:** [February 10, 2023, 4:10pm UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943/1 "2023-02-10T16:10:47Z")

</div>

In [Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera](https://www.coursera.org/learn/machine-learning-calculus/programming/7DDOo/optimization-using-gradient-descent-linear-regression/lab?path=%2Fnotebooks%2FC2_W2_Assignment.ipynb)

> Define cost function according to the equation (1)(1):
> 
> In [24]:
> 
> def E(m, b, X, Y):
> 
> return 1/(2\*len(Y))_np.sum(np.dot(m_X + b - Y, X))

There shouldn’t be a dot product - that is for the dEdm

---

<div class="post-metadata">

**Author:** ![lucas.coutinho](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/lucas.coutinho/32/155465_2.png) [@lucas.coutinho](https://community.deeplearning.ai/u/lucas.coutinho)\
**Post date:** [February 10, 2023, 5:05pm UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943/2 "2023-02-10T17:05:17Z")

</div>

Thanks for reporting this, @toontalk!

@esanina, when you get some time, can you have a look at this? Thanks!

Lucas

---

<div class="post-metadata">

**Author:** ![DietzscheNostoevsky](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/dietzschenostoevsky/32/34236_2.png) [@DietzscheNostoevsky](https://community.deeplearning.ai/u/DietzscheNostoevsky)\
**Post date:** [February 13, 2023, 4:26pm UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943/3 "2023-02-13T16:26:42Z")

</div>

I have been stuck on that line of code from last 1 hour, where did that dot product came from. I think that dot product is there to square the values. But still cant understand why dot with ‘X’.  
Was about to go over stackoverflow but decided to check here first.

Please resolve this

---

<div class="post-metadata">

**Author:** ![esanina](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/esanina/32/128749_2.png) [@esanina](https://community.deeplearning.ai/u/esanina)\
**Post date:** [February 13, 2023, 11:13pm UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943/4 "2023-02-13T23:13:43Z")

</div>

@toontalk @DietzscheNostoevsky sorry for confusion. It was a mistake in the code. We have fixed it now.

---

<div class="post-metadata">

**Author:** ![DietzscheNostoevsky](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/dietzschenostoevsky/32/34236_2.png) [@DietzscheNostoevsky](https://community.deeplearning.ai/u/DietzscheNostoevsky)\
**Post date:** [February 14, 2023, 1:34am UTC](https://community.deeplearning.ai/t/wrong-definition-of-e-in-c2-w2-assignment/271943/5 "2023-02-14T01:34:14Z")

</div>

Its been updated. Thank you.
