# Derivation of Backpropagation in RNNs

**URL:** <https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267>\
**Category:** Sequence Models\
**Tags:** week-module-1, coursera-platform\
**Created:** [May 25, 2024, 4:00am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267 "2024-05-25T04:00:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahesh-mantri](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mahesh-mantri](https://community.deeplearning.ai/u/mahesh-mantri)\
**Post date:** [May 25, 2024, 4:00am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267/1 "2024-05-25T04:00:08Z")

</div>

Can anybody helps me in derivation of those variables in back propagation -

 ![Screenshot 2024-05-25 at 9.29.07 AM](https://global.discourse-cdn.com/dlai/original/3X/1/c/1cb95b0785fa4abaa1c45081ba14b1a7c6713502.jpeg)

---

<div class="post-metadata">

**Author:** ![Alireza\_Saei](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/alireza_saei/32/85175_2.png) [@Alireza\_Saei](https://community.deeplearning.ai/u/Alireza_Saei)\
**Post date:** [May 25, 2024, 9:18am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267/2 "2024-05-25T09:18:51Z")

</div>

Hey there @mahesh-mantri ,

I assume that you want explanation for each one of them:

- **dtanh** → Derivative of `tanh` activation function w.r.t. the input to the activation function.

- **dW\_{ax}** → Gradient of the loss w.r.t. the weight matrix connecting the input to the current hidden state.

- **dW\_{aa}** → Gradient of the loss w.r.t. the weight matrix connecting the previous hidden state to the current hidden state.

- **db\_a** → The gradient of the loss w.r.t. the bias term in the hidden state update.

- **dx^{(t)}** → The gradient of the loss w.r.t. the input at time step `t`.

- **da\_{prev}** → Gradient of the loss w.r.t. the previous hidden state.

Feel free to ask if you need further assistance!

---

<div class="post-metadata">

**Author:** ![mahesh-mantri](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@mahesh-mantri](https://community.deeplearning.ai/u/mahesh-mantri)\
**Post date:** [May 25, 2024, 11:04am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267/3 "2024-05-25T11:04:31Z")

</div>

Hello @Alireza_Saei , I was asking for how we can derive these formulae , want to understand the math behind them.

---

<div class="post-metadata">

**Author:** ![Alireza\_Saei](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/alireza_saei/32/85175_2.png) [@Alireza\_Saei](https://community.deeplearning.ai/u/Alireza_Saei)\
**Post date:** [May 25, 2024, 11:25am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267/4 "2024-05-25T11:25:44Z")

</div>

These are some basic derivatives. You can find the formulas almost everywhere! Try to understand them yourself, but if you ever feel stuck, feel free to ask, and I can explain them!

---

<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:** [May 26, 2024, 2:12am UTC](https://community.deeplearning.ai/t/derivation-of-backpropagation-in-rnns/634267/5 "2024-05-26T02:12:46Z")

</div>

> [@mahesh-mantri](#):
>
> I was asking for how we can derive these formulae

This requires first that you understand calculus. If you do, then the derivatives are straightforward.
