# C2\_W4 gradient descent

**URL:** <https://community.deeplearning.ai/t/c2-w4-gradient-descent/114731>\
**Category:** NLP with Probabilistic Models\
**Tags:** week-module-4\
**Created:** [March 31, 2022, 6:02pm UTC](https://community.deeplearning.ai/t/c2-w4-gradient-descent/114731 "2022-03-31T18:02:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarun\_Saha](https://avatars.discourse-cdn.com/v4/letter/t/58956e/32.png) [@Tarun\_Saha](https://community.deeplearning.ai/u/Tarun_Saha)\
**Post date:** [March 31, 2022, 6:02pm UTC](https://community.deeplearning.ai/t/c2-w4-gradient-descent/114731/1 "2022-03-31T18:02:09Z")

</div>

I’m not getting expected cost value for the Gradient descent function in Exercise 05, the cost doesn’t seems to be changing much:  
Call gradient\_descent  
iters: 10 cost: 9.105433  
iters: 20 cost: 8.422988  
iters: 30 cost: 8.758872  
iters: 40 cost: 8.333231  
iters: 50 cost: 9.127138  
iters: 60 cost: 8.514464  
iters: 70 cost: 8.935792  
iters: 80 cost: 8.442537  
iters: 90 cost: 8.672371  
iters: 100 cost: 8.554414  
iters: 110 cost: 8.016827  
iters: 120 cost: 8.074106  
iters: 130 cost: 8.337460  
iters: 140 cost: 8.211384  
iters: 150 cost: 7.975324

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ai_curious/32/128003_2.png) [@ai\_curious](https://community.deeplearning.ai/u/ai_curious)\
**Post date:** [March 31, 2022, 6:47pm UTC](https://community.deeplearning.ai/t/c2-w4-gradient-descent/114731/2 "2022-03-31T18:47:18Z")

</div>

Assuming you passed the other unit tests and `forward_prop`, `compute_cost`, and `back_prop` all produce expected results. That leaves the implementation of _#update weights and biases_

Maybe compare your code to the equations in the lecture/reading [_Training a CBOW Model: Backpropagation and Gradient Descent_.](https://www.coursera.org/learn/probabilistic-models-in-nlp/supplement/EEbAq/training-a-cbow-model-backpropagation-and-gradient-descent)

W\_1 := W\_1 - \alpha \frac{\partial J\_{batch}}{\partial W\_1}  
W\_2 := W\_2 - \alpha \frac{\partial J\_{batch}}{\partial W\_2}  
b\_1 := b\_1 - \alpha \frac{\partial J\_{batch}}{\partial b\_1}  
b\_2 := b\_2 - \alpha \frac{\partial J\_{batch}}{\partial b\_2}

HINT: the partial derivative elements are computed in `back_prop()`
