# 2.4 嵌入矩阵（Embedding Matrix）

当应用算法来学习词嵌入时，实际上是学习一个**嵌入矩阵**

假设某个词汇库包含了10000个单词，每个单词包含的特征维度为300，那么表征所有单词的**embedding matrix**维度为300 x 10000，用$$E$$来表示。某单词$$w$$的one-hot向量表示为$$O\_w$$，维度为10000 x 1

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

则该单词的嵌入向量(embedding vector)表达式为：

$$
e\_w=E\cdot O\_w
$$

只要知道了embedding matrix$$E$$，就能计算出所有单词的embedding vector $$e\_w$$

不过上述这种矩阵乘积运算$$E\cdot O\_w$$效率并不高，矩阵维度很大，且$$O\_w$$大部分元素为零。通常做法是直接从$$E$$中选取第$$w$$列作为$$e\_w$$


---

# 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/natural-language-processing-and-word-embeddings/24-qian-ru-ju-zhen-ff08-embedding-matrix.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.
