Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
4c95acfc
B
book
项目概览
PaddlePaddle
/
book
通知
16
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
40
列表
看板
标记
里程碑
合并请求
37
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
B
book
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
40
Issue
40
列表
看板
标记
里程碑
合并请求
37
合并请求
37
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4c95acfc
编写于
3月 07, 2017
作者:
Y
Yi Wang
浏览文件
操作
浏览文件
下载
差异文件
Resolve conflicts
上级
01339b6f
5ba755bb
变更
51
显示空白变更内容
内联
并排
Showing
51 changed file
with
505 addition
and
516 deletion
+505
-516
.pre-commit-config.yaml
.pre-commit-config.yaml
+9
-6
.tmpl/marked.js
.tmpl/marked.js
+1
-1
fit_a_line/index.en.html
fit_a_line/index.en.html
+2
-1
fit_a_line/index.html
fit_a_line/index.html
+6
-5
gan/index.html
gan/index.html
+1
-1
image_caption/index.html
image_caption/index.html
+1
-1
image_classification/README.en.md
image_classification/README.en.md
+48
-48
image_classification/README.md
image_classification/README.md
+14
-14
image_classification/deprecated/README.md
image_classification/deprecated/README.md
+18
-18
image_classification/index.en.html
image_classification/index.en.html
+49
-49
image_classification/index.html
image_classification/index.html
+33
-33
image_detection/index.html
image_detection/index.html
+1
-1
image_qa/index.html
image_qa/index.html
+1
-1
index.html
index.html
+1
-10
label_semantic_roles/README.en.md
label_semantic_roles/README.en.md
+10
-10
label_semantic_roles/README.md
label_semantic_roles/README.md
+11
-11
label_semantic_roles/data/extract_pairs.py
label_semantic_roles/data/extract_pairs.py
+1
-1
label_semantic_roles/index.en.html
label_semantic_roles/index.en.html
+12
-12
label_semantic_roles/index.html
label_semantic_roles/index.html
+13
-13
label_semantic_roles/predict.sh
label_semantic_roles/predict.sh
+3
-3
machine_translation/README.en.md
machine_translation/README.en.md
+17
-17
machine_translation/README.md
machine_translation/README.md
+8
-8
machine_translation/data/wmt14_data.sh
machine_translation/data/wmt14_data.sh
+3
-3
machine_translation/eval_bleu.sh
machine_translation/eval_bleu.sh
+1
-1
machine_translation/index.en.html
machine_translation/index.en.html
+18
-18
machine_translation/index.html
machine_translation/index.html
+10
-11
machine_translation/pretrained/wmt14_model.sh
machine_translation/pretrained/wmt14_model.sh
+1
-1
pre-commit-hooks/convert_markdown_into_html.py
pre-commit-hooks/convert_markdown_into_html.py
+1
-1
query_relationship/index.html
query_relationship/index.html
+1
-1
recognize_digits/README.en.md
recognize_digits/README.en.md
+2
-2
recognize_digits/README.md
recognize_digits/README.md
+1
-1
recognize_digits/index.en.html
recognize_digits/index.en.html
+5
-5
recognize_digits/index.html
recognize_digits/index.html
+3
-3
recommender_system/README.en.md
recommender_system/README.en.md
+1
-1
recommender_system/README.md
recommender_system/README.md
+5
-5
recommender_system/index.en.html
recommender_system/index.en.html
+3
-3
recommender_system/index.html
recommender_system/index.html
+6
-7
recommender_system/preprocess.sh
recommender_system/preprocess.sh
+2
-2
skip_thought/index.html
skip_thought/index.html
+1
-1
speech_recognition/index.html
speech_recognition/index.html
+1
-1
understand_sentiment/README.en.md
understand_sentiment/README.en.md
+7
-7
understand_sentiment/README.md
understand_sentiment/README.md
+1
-1
understand_sentiment/data/get_imdb.sh
understand_sentiment/data/get_imdb.sh
+1
-1
understand_sentiment/index.en.html
understand_sentiment/index.en.html
+9
-9
understand_sentiment/index.html
understand_sentiment/index.html
+12
-12
understand_sentiment/preprocess.py
understand_sentiment/preprocess.py
+1
-1
word2vec/README.en.md
word2vec/README.en.md
+34
-34
word2vec/README.md
word2vec/README.md
+24
-24
word2vec/format_convert.py
word2vec/format_convert.py
+9
-9
word2vec/index.en.html
word2vec/index.en.html
+35
-35
word2vec/index.html
word2vec/index.html
+47
-52
未找到文件。
.pre-commit-config.yaml
浏览文件 @
4c95acfc
-
repo
:
https://github.com/Lucas-C/pre-commit-hooks.git
sha
:
c25201a00e6b0514370501050cf2a8538ac12270
hooks
:
-
id
:
remove-crlf
-
repo
:
https://github.com/reyoung/mirrors-yapf.git
sha
:
v0.13.2
hooks
:
-
id
:
yapf
files
:
(.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
# Bazel BUILD files follow Python syntax.
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
sha
:
7539d8bd1a00a3c1bfd34cdb606d3a6372e83469
sha
:
v0.7.1
hooks
:
-
id
:
check-merge-conflict
-
id
:
check-symlinks
-
id
:
detect-private-key
-
id
:
end-of-file-fixer
-
id
:
trailing-whitespace
-
repo
:
git://github.com/Lucas-C/pre-commit-hooks
sha
:
v1.0.1
hooks
:
-
id
:
forbid-crlf
-
id
:
remove-crlf
-
id
:
forbid-tabs
-
id
:
remove-tabs
-
repo
:
local
hooks
:
-
id
:
convert-markdown-into-html
...
...
.tmpl/marked.js
浏览文件 @
4c95acfc
fit_a_line/index.en.html
浏览文件 @
4c95acfc
...
...
@@ -176,6 +176,7 @@ y_predict = paddle.layer.fc(input=x,
y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))
cost = paddle.layer.regression_cost(input=y_predict, label=y)
```
### Create Parameters
```python
...
...
fit_a_line/index.html
浏览文件 @
4c95acfc
...
...
@@ -170,6 +170,7 @@ y_predict = paddle.layer.fc(input=x,
y = paddle.layer.data(name='y', type=paddle.data_type.dense_vector(1))
cost = paddle.layer.regression_cost(input=y_predict, label=y)
```
### 创建参数
```python
...
...
gan/index.html
浏览文件 @
4c95acfc
image_caption/index.html
浏览文件 @
4c95acfc
image_classification/README.en.md
浏览文件 @
4c95acfc
image_classification/README.md
浏览文件 @
4c95acfc
image_classification/deprecated/README.md
浏览文件 @
4c95acfc
image_classification/index.en.html
浏览文件 @
4c95acfc
image_classification/index.html
浏览文件 @
4c95acfc
image_detection/index.html
浏览文件 @
4c95acfc
image_qa/index.html
浏览文件 @
4c95acfc
index.html
浏览文件 @
4c95acfc
...
...
@@ -21,15 +21,6 @@
<link
href=
"http://cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
rel=
"stylesheet"
>
<link
href=
"https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css"
rel=
"stylesheet"
>
<link
href=
"../.tmpl/github-markdown.css"
rel=
'stylesheet'
>
</head>
<style
type=
"text/css"
>
.markdown-body
{
box-sizing
:
border-box
;
min-width
:
200px
;
max-width
:
980px
;
margin
:
0
auto
;
padding
:
45px
;
}
</style>
...
...
label_semantic_roles/README.en.md
浏览文件 @
4c95acfc
label_semantic_roles/README.md
浏览文件 @
4c95acfc
label_semantic_roles/data/extract_pairs.py
浏览文件 @
4c95acfc
label_semantic_roles/index.en.html
浏览文件 @
4c95acfc
label_semantic_roles/index.html
浏览文件 @
4c95acfc
label_semantic_roles/predict.sh
浏览文件 @
4c95acfc
machine_translation/README.en.md
浏览文件 @
4c95acfc
machine_translation/README.md
浏览文件 @
4c95acfc
machine_translation/data/wmt14_data.sh
浏览文件 @
4c95acfc
machine_translation/eval_bleu.sh
浏览文件 @
4c95acfc
machine_translation/index.en.html
浏览文件 @
4c95acfc
machine_translation/index.html
浏览文件 @
4c95acfc
...
...
@@ -352,7 +352,6 @@ wmt14_reader = paddle.batch(
- gru_step通过调用`gru_step_layer`函数,在decoder_inputs和decoder_mem上做了激活操作,即实现公式$z_{i+1}=\phi _{\theta '}\left ( c_i,u_i,z_i \right )$。
- 最后,使用softmax归一化计算单词的概率,将out结果返回,即实现公式$p\left ( u_i|u_{
<
i},\mathbf{x} \right )=softmax(W_sz_i+b_z)$。
```python
def gru_decoder_with_attention(enc_vec, enc_proj, current_word):
...
...
machine_translation/pretrained/wmt14_model.sh
浏览文件 @
4c95acfc
pre-commit-hooks/convert_markdown_into_html.py
浏览文件 @
4c95acfc
query_relationship/index.html
浏览文件 @
4c95acfc
recognize_digits/README.en.md
浏览文件 @
4c95acfc
recognize_digits/README.md
浏览文件 @
4c95acfc
recognize_digits/index.en.html
浏览文件 @
4c95acfc
recognize_digits/index.html
浏览文件 @
4c95acfc
recommender_system/README.en.md
浏览文件 @
4c95acfc
recommender_system/README.md
浏览文件 @
4c95acfc
recommender_system/index.en.html
浏览文件 @
4c95acfc
recommender_system/index.html
浏览文件 @
4c95acfc
...
...
@@ -334,7 +334,6 @@ parameters = paddle.parameters.create(cost)
`parameters`是模型的所有参数集合。他是一个python的dict。我们可以查看到这个网络中的所有参数名称。因为之前定义模型的时候,我们没有指定参数名称,这里参数名称是自动生成的。当然,我们也可以指定每一个参数名称,方便日后维护。
```python
print parameters.keys()
```
...
...
recommender_system/preprocess.sh
浏览文件 @
4c95acfc
skip_thought/index.html
浏览文件 @
4c95acfc
speech_recognition/index.html
浏览文件 @
4c95acfc
understand_sentiment/README.en.md
浏览文件 @
4c95acfc
understand_sentiment/README.md
浏览文件 @
4c95acfc
understand_sentiment/data/get_imdb.sh
浏览文件 @
4c95acfc
understand_sentiment/index.en.html
浏览文件 @
4c95acfc
understand_sentiment/index.html
浏览文件 @
4c95acfc
understand_sentiment/preprocess.py
浏览文件 @
4c95acfc
word2vec/README.en.md
浏览文件 @
4c95acfc
word2vec/README.md
浏览文件 @
4c95acfc
word2vec/format_convert.py
浏览文件 @
4c95acfc
word2vec/index.en.html
浏览文件 @
4c95acfc
word2vec/index.html
浏览文件 @
4c95acfc
...
...
@@ -251,7 +251,6 @@ N = 5 # 训练5-Gram
接着,定义网络结构:
- 将$w_t$之前的$n-1$个词 $w_{t-n+1},...w_{t-1}$,通过$|V|\times D$的矩阵映射到D维词向量(本例中取D=32)。
```python
def wordemb(inlayer):
wordemb = paddle.layer.table_projection(
...
...
@@ -379,7 +378,6 @@ trainer.train(
## 应用模型
训练模型后,我们可以加载模型参数,用训练出来的词向量初始化其他模型,也可以将模型查看参数用来做后续应用。
### 查看词向量
PaddlePaddle训练出来的参数可以直接使用`parameters.get()`获取出来。例如查看单词的word的词向量,即为
...
...
@@ -429,9 +427,6 @@ emb_2 = embeddings[word_dict['would']]
print spatial.distance.cosine(emb_1, emb_2)
```
0.99375076448
## 总结
本章中,我们介绍了词向量、语言模型和词向量的关系、以及如何通过训练神经网络模型获得词向量。在信息检索中,我们可以根据向量间的余弦夹角,来判断query和文档关键词这二者间的相关性。在句法分析和语义分析中,训练好的词向量可以用来初始化模型,以得到更好的效果。在文档分类中,有了词向量之后,可以用聚类的方法将文档中同义词进行分组。希望大家在本章后能够自行运用词向量进行相关领域的研究。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录