Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
788dc32a
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看板
提交
788dc32a
编写于
10月 23, 2017
作者:
P
Peng Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change parameters.to_tar(f) in *.md to trainer.save_parameter_to_tar(f)
上级
c7ed5286
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
31 addition
and
31 deletion
+31
-31
01.fit_a_line/README.cn.md
01.fit_a_line/README.cn.md
+1
-1
01.fit_a_line/README.md
01.fit_a_line/README.md
+1
-1
01.fit_a_line/index.cn.html
01.fit_a_line/index.cn.html
+1
-1
01.fit_a_line/index.html
01.fit_a_line/index.html
+1
-1
02.recognize_digits/README.cn.md
02.recognize_digits/README.cn.md
+2
-2
02.recognize_digits/README.md
02.recognize_digits/README.md
+2
-2
02.recognize_digits/index.cn.html
02.recognize_digits/index.cn.html
+2
-2
02.recognize_digits/index.html
02.recognize_digits/index.html
+2
-2
03.image_classification/README.cn.md
03.image_classification/README.cn.md
+1
-1
03.image_classification/README.md
03.image_classification/README.md
+1
-1
03.image_classification/index.cn.html
03.image_classification/index.cn.html
+1
-1
03.image_classification/index.html
03.image_classification/index.html
+1
-1
04.word2vec/README.cn.md
04.word2vec/README.cn.md
+1
-1
04.word2vec/README.md
04.word2vec/README.md
+1
-1
04.word2vec/index.cn.html
04.word2vec/index.cn.html
+1
-1
04.word2vec/index.html
04.word2vec/index.html
+1
-1
06.understand_sentiment/README.cn.md
06.understand_sentiment/README.cn.md
+1
-1
06.understand_sentiment/README.md
06.understand_sentiment/README.md
+1
-1
06.understand_sentiment/index.cn.html
06.understand_sentiment/index.cn.html
+1
-1
06.understand_sentiment/index.html
06.understand_sentiment/index.html
+1
-1
07.label_semantic_roles/README.cn.md
07.label_semantic_roles/README.cn.md
+1
-1
07.label_semantic_roles/README.md
07.label_semantic_roles/README.md
+1
-1
07.label_semantic_roles/index.cn.html
07.label_semantic_roles/index.cn.html
+1
-1
07.label_semantic_roles/index.html
07.label_semantic_roles/index.html
+1
-1
serve/README.md
serve/README.md
+3
-3
未找到文件。
01.fit_a_line/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -214,7 +214,7 @@ def event_handler_plot(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
if
event
.
pass_id
%
10
==
0
:
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
```
### 开始训练
...
...
01.fit_a_line/README.md
浏览文件 @
788dc32a
...
...
@@ -220,7 +220,7 @@ def event_handler_plot(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
if
event
.
pass_id
%
10
==
0
:
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
```
### Start Training
...
...
01.fit_a_line/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -256,7 +256,7 @@ def event_handler_plot(event):
if isinstance(event, paddle.event.EndPass):
if event.pass_id % 10 == 0:
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
```
### 开始训练
...
...
01.fit_a_line/index.html
浏览文件 @
788dc32a
...
...
@@ -262,7 +262,7 @@ def event_handler_plot(event):
if isinstance(event, paddle.event.EndPass):
if event.pass_id % 10 == 0:
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
```
### Start Training
...
...
02.recognize_digits/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -256,7 +256,7 @@ def event_handler_plot(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
...
...
@@ -275,7 +275,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
...
...
02.recognize_digits/README.md
浏览文件 @
788dc32a
...
...
@@ -249,7 +249,7 @@ def event_handler_plot(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
...
...
@@ -270,7 +270,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
...
...
02.recognize_digits/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -298,7 +298,7 @@ def event_handler_plot(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
...
...
@@ -317,7 +317,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
...
...
02.recognize_digits/index.html
浏览文件 @
788dc32a
...
...
@@ -291,7 +291,7 @@ def event_handler_plot(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
...
...
@@ -312,7 +312,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
...
...
03.image_classification/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -432,7 +432,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
...
...
03.image_classification/README.md
浏览文件 @
788dc32a
...
...
@@ -438,7 +438,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
...
...
03.image_classification/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -474,7 +474,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(
reader=paddle.batch(
...
...
03.image_classification/index.html
浏览文件 @
788dc32a
...
...
@@ -480,7 +480,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(
reader=paddle.batch(
...
...
04.word2vec/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -336,7 +336,7 @@ def event_handler(event):
paddle
.
dataset
.
imikolov
.
test
(
word_dict
,
N
),
32
))
print
"Pass %d, Testing metrics %s"
%
(
event
.
pass_id
,
result
.
metrics
)
with
open
(
"model_%d.tar"
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
trainer
.
train
(
paddle
.
batch
(
paddle
.
dataset
.
imikolov
.
train
(
word_dict
,
N
),
32
),
...
...
04.word2vec/README.md
浏览文件 @
788dc32a
...
...
@@ -348,7 +348,7 @@ def event_handler(event):
paddle
.
dataset
.
imikolov
.
test
(
word_dict
,
N
),
32
))
print
"Pass %d, Testing metrics %s"
%
(
event
.
pass_id
,
result
.
metrics
)
with
open
(
"model_%d.tar"
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
trainer
.
train
(
paddle
.
batch
(
paddle
.
dataset
.
imikolov
.
train
(
word_dict
,
N
),
32
),
...
...
04.word2vec/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -378,7 +378,7 @@ def event_handler(event):
paddle.dataset.imikolov.test(word_dict, N), 32))
print "Pass %d, Testing metrics %s" % (event.pass_id, result.metrics)
with open("model_%d.tar"%event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
trainer.train(
paddle.batch(paddle.dataset.imikolov.train(word_dict, N), 32),
...
...
04.word2vec/index.html
浏览文件 @
788dc32a
...
...
@@ -390,7 +390,7 @@ def event_handler(event):
paddle.dataset.imikolov.test(word_dict, N), 32))
print "Pass %d, Testing metrics %s" % (event.pass_id, result.metrics)
with open("model_%d.tar"%event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
trainer.train(
paddle.batch(paddle.dataset.imikolov.train(word_dict, N), 32),
...
...
06.understand_sentiment/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -291,7 +291,7 @@ Paddle中提供了一系列优化算法的API,这里使用Adam优化算法。
sys
.
stdout
.
flush
()
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
with
open
(
'./params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
test_reader
,
feeding
=
feeding
)
print
"
\n
Test with Pass %d, %s"
%
(
event
.
pass_id
,
result
.
metrics
)
...
...
06.understand_sentiment/README.md
浏览文件 @
788dc32a
...
...
@@ -310,7 +310,7 @@ def event_handler(event):
sys
.
stdout
.
flush
()
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
with
open
(
'./params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
test_reader
,
feeding
=
feeding
)
print
"
\n
Test with Pass %d, %s"
%
(
event
.
pass_id
,
result
.
metrics
)
...
...
06.understand_sentiment/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -333,7 +333,7 @@ Paddle中提供了一系列优化算法的API,这里使用Adam优化算法。
sys.stdout.flush()
if isinstance(event, paddle.event.EndPass):
with open('./params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=test_reader, feeding=feeding)
print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics)
...
...
06.understand_sentiment/index.html
浏览文件 @
788dc32a
...
...
@@ -352,7 +352,7 @@ def event_handler(event):
sys.stdout.flush()
if isinstance(event, paddle.event.EndPass):
with open('./params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=test_reader, feeding=feeding)
print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics)
...
...
07.label_semantic_roles/README.cn.md
浏览文件 @
788dc32a
...
...
@@ -448,7 +448,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
reader
,
feeding
=
feeding
)
print
"
\n
Test with Pass %d, %s"
%
(
event
.
pass_id
,
result
.
metrics
)
...
...
07.label_semantic_roles/README.md
浏览文件 @
788dc32a
...
...
@@ -466,7 +466,7 @@ def event_handler(event):
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
open
(
'params_pass_%d.tar'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
reader
,
feeding
=
feeding
)
print
"
\n
Test with Pass %d, %s"
%
(
event
.
pass_id
,
result
.
metrics
)
...
...
07.label_semantic_roles/index.cn.html
浏览文件 @
788dc32a
...
...
@@ -490,7 +490,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=reader, feeding=feeding)
print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics)
...
...
07.label_semantic_roles/index.html
浏览文件 @
788dc32a
...
...
@@ -508,7 +508,7 @@ def event_handler(event):
if isinstance(event, paddle.event.EndPass):
# save parameters
with open('params_pass_%d.tar' % event.pass_id, 'w') as f:
parameters.
to_tar(f)
trainer.save_parameter_
to_tar(f)
result = trainer.test(reader=reader, feeding=feeding)
print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics)
...
...
serve/README.md
浏览文件 @
788dc32a
...
...
@@ -61,12 +61,12 @@ PaddlePaddle stores the topology and parameter separately.
inference_topology
.
serialize_for_inference
(
f
)
```
2.
To save a parameter, we need to invoke
`
to_tar`
method in Parameter
class
.
2.
To save a parameter, we need to invoke
`
save_parameter_to_tar`
method of
`trainer`
.
```
python
with
open
(
'param.tar'
,
'w'
)
as
f
:
params
.
to_tar
(
f
)
trainer
.
save_parameter_
to_tar
(
f
)
```
After serializing the parameter and topology into two files, we could
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录