# Course 1 Week 2 A2 np dot leads to nan

**URL:** <https://community.deeplearning.ai/t/course-1-week-2-a2-np-dot-leads-to-nan/384364>\
**Category:** Neural Networks and Deep Learning\
**Tags:** coursera-platform\
**Created:** [July 13, 2023, 3:52pm UTC](https://community.deeplearning.ai/t/course-1-week-2-a2-np-dot-leads-to-nan/384364 "2023-07-13T15:52:07Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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, 2023, 12:00am UTC](https://community.deeplearning.ai/t/course-1-week-2-a2-np-dot-leads-to-nan/384364/4 "2023-07-14T00:00:57Z")

</div>

Gradient Descent does not actually depend on the J values themselves, just the derivatives of J w.r.t. the various parameters. So Gradient Descent still works, even if your cost function is throwing NaNs, because your sigmoid values have “saturated”. But you can also add logic to detect and avoid the saturation cases. [Here’s a thread](https://community.deeplearning.ai/t/cost-function-problem/108146/2) which discusses this in more detail.

---

_[View the full topic](https://community.deeplearning.ai/t/course-1-week-2-a2-np-dot-leads-to-nan/384364)._
