Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
5ecfe40d
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看板
未验证
提交
5ecfe40d
编写于
7月 19, 2018
作者:
D
dzhwinter
提交者:
GitHub
7月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #583 from JiabinYang/book04_refine
Refine the presentation format for '04.word2vect'
上级
804beca1
cefab6bb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
10 deletion
+12
-10
04.word2vec/README.cn.md
04.word2vec/README.cn.md
+4
-4
04.word2vec/README.md
04.word2vec/README.md
+2
-1
04.word2vec/index.cn.html
04.word2vec/index.cn.html
+4
-4
04.word2vec/index.html
04.word2vec/index.html
+2
-1
未找到文件。
04.word2vec/README.cn.md
浏览文件 @
5ecfe40d
...
...
@@ -204,6 +204,7 @@ from functools import partial
import
math
import
os
import
sys
from
__future__
import
print_function
```
然后,定义参数:
...
...
@@ -311,7 +312,7 @@ def train(use_cuda, train_program, params_dirname):
feed_order
=
[
'firstw'
,
'secondw'
,
'thirdw'
,
'fourthw'
,
'nextw'
])
avg_cost
=
outs
[
0
]
print
"Step %d: Average Cost %f"
%
(
event
.
step
,
avg_cost
)
print
(
"Step %d: Average Cost %f"
%
(
event
.
step
,
avg_cost
)
)
# If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should
...
...
@@ -337,7 +338,7 @@ def train(use_cuda, train_program, params_dirname):
-
`trainer.train`
将会开始训练。从
`event_handler`
返回的监控情况如下:
```
python
```
text
Step 0: Average Cost 7.337213
Step 10: Average Cost 6.136128
Step 20: Average Cost 5.766995
...
...
@@ -394,8 +395,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
在经历3分钟的短暂训练后,我们得到如下的预测。我们的模型预测
`among a group of`
的下一个词是
`a`
。这比较符合文法规律。如果我们训练时间更长,比如几个小时,那么我们会得到的下一个预测是
`workers`
。
```
python
```
text
[[0.00106646 0.0007907 0.00072041 ... 0.00049024 0.00041355 0.00084464]]
6
a
...
...
04.word2vec/README.md
浏览文件 @
5ecfe40d
...
...
@@ -222,6 +222,7 @@ from functools import partial
import
math
import
os
import
sys
from
__future__
import
print_function
```
-
Configure parameters and build word dictionary.
...
...
@@ -328,7 +329,7 @@ def train(use_cuda, train_program, params_dirname):
# We output cost every 10 steps.
if
event
.
step
%
10
==
0
:
print
"Step %d: Average Cost %f"
%
(
event
.
step
,
avg_cost
)
print
(
"Step %d: Average Cost %f"
%
(
event
.
step
,
avg_cost
)
)
# If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should
...
...
04.word2vec/index.cn.html
浏览文件 @
5ecfe40d
...
...
@@ -246,6 +246,7 @@ from functools import partial
import math
import os
import sys
from __future__ import print_function
```
然后,定义参数:
...
...
@@ -353,7 +354,7 @@ def train(use_cuda, train_program, params_dirname):
feed_order=['firstw', 'secondw', 'thirdw', 'fourthw', 'nextw'])
avg_cost = outs[0]
print
"Step %d: Average Cost %f" % (event.step, avg_cost
)
print
("Step %d: Average Cost %f" % (event.step, avg_cost)
)
# If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should
...
...
@@ -379,7 +380,7 @@ def train(use_cuda, train_program, params_dirname):
-
`
trainer.train
`
将会开始训练
。
从
`
event_handler
`
返回的监控情况如下
:
```
python
```
text
Step
0
:
Average
Cost
7.337213
Step
10
:
Average
Cost
6.136128
Step
20
:
Average
Cost
5.766995
...
...
@@ -436,8 +437,7 @@ def infer(use_cuda, inference_program, params_dirname=None):
在经历3分钟的短暂训练后
,
我们得到如下的预测
。
我们的模型预测
`
among
a
group
of
`
的下一个词是
`
a
`。
这比较符合文法规律
。
如果我们训练时间更长
,
比如几个小时
,
那么我们会得到的下一个预测是
`
workers
`。
```
python
```
text
[[0.00106646
0.0007907
0.00072041
...
0.00049024
0.00041355
0.00084464]]
6
a
...
...
04.word2vec/index.html
浏览文件 @
5ecfe40d
...
...
@@ -264,6 +264,7 @@ from functools import partial
import math
import os
import sys
from __future__ import print_function
```
- Configure parameters and build word dictionary.
...
...
@@ -370,7 +371,7 @@ def train(use_cuda, train_program, params_dirname):
# We output cost every 10 steps.
if event.step % 10 == 0:
print
"Step %d: Average Cost %f" % (event.step, avg_cost
)
print
("Step %d: Average Cost %f" % (event.step, avg_cost)
)
# If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录