# 1.4 通过时间的反向传播（Backpropagation through time）

反向传播计算方向与前向传播基本上是相反：

[![](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/998c7af4f90cd0de0c88f138b61f0168.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/998c7af4f90cd0de0c88f138b61f0168.png)

识别人名的例子，经过RNN正向传播，单个元素的Loss function为：

$$
L^{<t>}(\hat y^{<t>},y^{<t>})=-y^{<t>}log\ \hat y^{<t>}-(1-y^{<t>})log\ (1-\hat y^{<t>})
$$

> 这是 binary classification 的 Loss Function，注意与1.6 的softmax Loss Function区别

该样本所有元素的Loss function为：

$$
L(\hat y,y)=\sum\_{t=1}^{T\_y}L^{<t>}(\hat y^{<t>},y^{<t>})
$$

反向传播（Backpropagation）过程就是从右到左分别计算$$L(\hat y,y)$$对参数$$W\_{a}$$，$$W\_{y}$$，$$b\_a$$，$$b\_y$$的偏导数，这种从右到左的求导过程被称为Backpropagation through time

**RNN**反向传播示意图：

[![nn\_cell\_backpro](https://github.com/fengdu78/deeplearning_ai_books/raw/master/images/rnn_cell_backprop.png)](https://github.com/fengdu78/deeplearning_ai_books/blob/master/images/rnn_cell_backprop.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://baozoulin.gitbook.io/neural-networks-and-deep-learning/di-wu-men-ke-xu-lie-mo-xing-sequence-models/di-wu-men-kexulie-mo-578b28-sequence-models/recurrent-neural-networks/14-tong-guo-shi-jian-de-fan-xiang-chuan-bo-ff08-backpropagation-through-time.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
