# Hi In The #Week 3 Assigment i Have tried my code in 2 different method Gettin wrpng in np.dot methos can someone clarify please

**URL:** <https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736>\
**Category:** Neural Networks and Deep Learning\
**Tags:** cnn, how-to-forum, coursera-platform\
**Created:** [June 15, 2024, 12:41pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736 "2024-06-15T12:41:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![arunKumarv1530](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@arunKumarv1530](https://community.deeplearning.ai/u/arunKumarv1530)\
**Post date:** [June 15, 2024, 12:41pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/1 "2024-06-15T12:41:49Z")

</div>

#week-3  
#[Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera](https://www.coursera.org/learn/neural-networks-deep-learning/programming/thQd4/logistic-regression-with-a-neural-network-mindset/lab?path=%2Fnotebooks%2Frelease%2FW2A2%2FLogistic_Regression_with_a_Neural_Network_mindset.ipynb)

{mentor edit: code removed}

Getting error

 ![Screenshot from 2024-06-15 18-10-33](https://global.discourse-cdn.com/dlai/original/3X/9/0/903ec73714a7de0cbcd1ff852af37c3b1a93eb2a.png)

#Getting correct answer in this code

{mentor edit: code removed}

---

<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:** [June 15, 2024, 3:05pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/2 "2024-06-15T15:05:07Z")

</div>

Please do not post your code on the forum. That’s not allowed by the Code of Conduct.

If a mentor needs to see your code, we’ll contact you with instructions.

You can post any error messages or asserts, those are usually sufficient to identify a problem.

I’ll edit your message to remove the code.

Hints:

- Use your sigmoid() function, don’t duplicate the code inside the propagate() function.
- Check your parenthesis grouping, the multiplication by -1/m needs to apply to the entire sum.

---

<div class="post-metadata">

**Author:** ![saifkhanengr](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/saifkhanengr/32/152858_2.png) [@saifkhanengr](https://community.deeplearning.ai/u/saifkhanengr)\
**Post date:** [June 15, 2024, 3:05pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/3 "2024-06-15T15:05:29Z")

</div>

> [@arunKumarv1530](#):
>
> #Getting correct answer in this code

This code is indeed correct. What is your question?

---

<div class="post-metadata">

**Author:** ![arunKumarv1530](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@arunKumarv1530](https://community.deeplearning.ai/u/arunKumarv1530)\
**Post date:** [June 15, 2024, 3:29pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/4 "2024-06-15T15:29:13Z")

</div>

While using np.dot in cost it’s coming as error

---

<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:** [June 15, 2024, 4:20pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/5 "2024-06-15T16:20:36Z")

</div>

There are several ways to compute the A and cost values.

- np.dot can be used in both computing A and cost.

- If you use np.dot in computing the cost, you do not need to use np.sum(). The dot product automatically computes the sum.

---

<div class="post-metadata">

**Author:** ![arunKumarv1530](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@arunKumarv1530](https://community.deeplearning.ai/u/arunKumarv1530)\
**Post date:** [June 15, 2024, 4:35pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/6 "2024-06-15T16:35:06Z")

</div>

I am getting the error show in the image on computing cost with np.dot

---

<div class="post-metadata">

**Author:** ![arunKumarv1530](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@arunKumarv1530](https://community.deeplearning.ai/u/arunKumarv1530)\
**Post date:** [June 15, 2024, 4:35pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/7 "2024-06-15T16:35:43Z")

</div>

Should I do with transpose?

---

<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:** [June 15, 2024, 5:02pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/8 "2024-06-15T17:02:29Z")

</div>

It depends on the shapes and order of the arguments.

---

<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:** [June 15, 2024, 5:03pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/9 "2024-06-15T17:03:08Z")

</div>

Use a print() statement to investigate the shapes.

---

<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:** [June 15, 2024, 5:37pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/10 "2024-06-15T17:37:06Z")

</div>

> [@arunKumarv1530](#):
>
> Should I do with transpose?

It requires that you understand how dot products work. The key point is that the “inner” dimensions need to agree. So with two 1 x 3 objects, you have two choices:

1 x 3 dot 3 x 1 yields a 1 x 1 or scalar output  
3 x 1 dot 1 x 3 yields a 3 x 3 output

[Here’s a thread](https://community.deeplearning.ai/t/week3-programming-assignment-4-4-compute-the-cost/18646/6) which talks about this choice and gives examples to demonstrate that those two give very different results.

One other important thing to understand is about how the notebooks work: if you type new code into a function cell and then run the test that calls that function again, it does nothing. It just ends up running the old code again. In order to get your newly entered code “activated” or compiled, you need to either click “Shift-Enter” on the changed cell before you call it again or you can restart everything by doing:

Kernel → Restart and Clear Output  
Cell → Run All

That will get everything back in sync again and WYSIWYG.

---

<div class="post-metadata">

**Author:** ![arunKumarv1530](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@arunKumarv1530](https://community.deeplearning.ai/u/arunKumarv1530)\
**Post date:** [June 15, 2024, 7:28pm UTC](https://community.deeplearning.ai/t/hi-in-the-week-3-assigment-i-have-tried-my-code-in-2-different-method-gettin-wrpng-in-np-dot-methos-can-someone-clarify-please/647736/11 "2024-06-15T19:28:13Z")

</div>

Oh Got it Thank y all for solving it .
