> For the complete documentation index, see [llms.txt](https://baozoulin.gitbook.io/neural-networks-and-deep-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](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/12-shu-xue-fu-hao-ff08-notation.md).

# 1.2 数学符号（Notation）

序列模型的输入语句是：“**Harry Potter and Herminoe Granger invented a new spell.**”。假如想要建立一个能够自动识别句中人名位置的序列模型，那么这就是一个命名实体识别问题

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

该句话包含9个单词，输出y即为1 x 9向量，每位表征对应单词是否为人名的一部分，对应的输出y表示为：

$$
y=\[1\ \ 1\ \ 0\ \ 1\ \ 1\ \ 0\ \ 0\ \ 0\ \ 0]^T
$$

$$y^{<t>}$$表示序列对应位置的输出，$$T\_y$$表示输出序列长度，$$1\leq t\leq T\_y$$

对于输入$$x$$，表示为：

$$
\[x^{<1>}\ \ x^{<2>}\ \ x^{<3>}\ \ x^{<4>}\ \ x^{<5>}\ \ x^{<6>}\ \ x^{<7>}\ \ x^{<8>}\ \ x^{<9>}]
$$

$$x^{<t>}$$表示序列对应位置的输入，$$T\_x$$表示输入序列长度。此例中$$T\_x=T\_y$$，但是也存在$$T\_x\neq T\_y$$

如何表示每个$$x^{<t>}$$：

建立一个词汇库vocabulary，尽可能包含更多的词汇。例如一个包含10000个词汇的词汇库为：

$$
\left\[
\begin{matrix}
a \\
and \\
\cdot \\
\cdot \\
\cdot \\
harry \\
\cdot \\
\cdot \\
\cdot \\
potter \\
\cdot \\
\cdot \\
\cdot \\
zulu
\end{matrix}
\right]
$$

然后使用one-hot编码，词汇表中与$$x^{<t>}$$对应的位置为1，其它位置为0。如果出现词汇表之外的单词，可以使用UNK或其他字符串来表示

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

对于多样本：对应的命名规则可表示为：$$X^{(i)<t>}$$，$$Y^{(i)<t>}$$，$$T\_x^{(i)}$$，$$T\_y^{(i)}$$，$$i$$表示第$$i$$个样本。不同样本的$$T\_x^{(i)}$$或$$T\_y^{(i)}$$都有可能不同
