Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
b03aadf1
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b03aadf1
编写于
12月 15, 2017
作者:
T
Travis CI
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deploy to GitHub Pages:
d5cab4f0
上级
6dbcdf91
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
2 deletion
+55
-2
develop/doc_cn/_sources/getstarted/concepts/use_concepts_cn.rst.txt
...c_cn/_sources/getstarted/concepts/use_concepts_cn.rst.txt
+5
-0
develop/doc_cn/getstarted/concepts/use_concepts_cn.html
develop/doc_cn/getstarted/concepts/use_concepts_cn.html
+49
-1
develop/doc_cn/searchindex.js
develop/doc_cn/searchindex.js
+1
-1
未找到文件。
develop/doc_cn/_sources/getstarted/concepts/use_concepts_cn.rst.txt
浏览文件 @
b03aadf1
...
...
@@ -147,4 +147,9 @@ PaddlePaddle支持不同类型的输入数据,主要包括四种类型,和
.. literalinclude:: src/train.py
:linenos:
使用以上训练好的模型进行预测,取其中一个模型params_pass_90.tar,输入需要预测的向量组,然后打印输出:
.. literalinclude:: src/infer.py
:linenos:
有关线性回归的实际应用,可以参考PaddlePaddle book的 `第一章节 <http://book.paddlepaddle.org/index.html>`_。
develop/doc_cn/getstarted/concepts/use_concepts_cn.html
浏览文件 @
b03aadf1
...
...
@@ -400,7 +400,12 @@ trainer.train<span class="o">(</span>
49
50
51
52
</pre></div></td><td
class=
"code"
><div
class=
"highlight"
><pre><span></span><span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
paddle.v2
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
paddle
</span>
52
53
54
55
56
57
</pre></div></td><td
class=
"code"
><div
class=
"highlight"
><pre><span></span><span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
paddle.v2
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
paddle
</span>
<span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
numpy
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
np
</span>
<span
class=
"c1"
>
# init paddle
</span>
...
...
@@ -428,6 +433,11 @@ trainer.train<span class="o">(</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
batch_id
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"mi"
>
1
</span>
<span
class=
"o"
>
==
</span>
<span
class=
"mi"
>
0
</span><span
class=
"p"
>
:
</span>
<span
class=
"nb"
>
print
</span>
<span
class=
"s2"
>
"
Pass
</span><span
class=
"si"
>
%d
</span><span
class=
"s2"
>
, Batch
</span><span
class=
"si"
>
%d
</span><span
class=
"s2"
>
, Cost
</span><span
class=
"si"
>
%f
</span><span
class=
"s2"
>
"
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"p"
>
(
</span><span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
pass_id
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
batch_id
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
cost
</span><span
class=
"p"
>
)
</span>
<span
class=
"c1"
>
# product model every 10 pass
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"nb"
>
isinstance
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
event
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
EndPass
</span><span
class=
"p"
>
):
</span>
<span
class=
"k"
>
if
</span>
<span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
pass_id
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"mi"
>
10
</span>
<span
class=
"o"
>
==
</span>
<span
class=
"mi"
>
0
</span><span
class=
"p"
>
:
</span>
<span
class=
"k"
>
with
</span>
<span
class=
"nb"
>
open
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
params_pass_
</span><span
class=
"si"
>
%d
</span><span
class=
"s1"
>
.tar
'
</span>
<span
class=
"o"
>
%
</span>
<span
class=
"n"
>
event
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
pass_id
</span><span
class=
"p"
>
,
</span>
<span
class=
"s1"
>
'
w
'
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"n"
>
f
</span><span
class=
"p"
>
:
</span>
<span
class=
"n"
>
trainer
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
save_parameter_to_tar
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
f
</span><span
class=
"p"
>
)
</span>
<span
class=
"c1"
>
# define training dataset reader
</span>
...
...
@@ -454,6 +464,44 @@ trainer.train<span class="o">(</span>
<span
class=
"n"
>
num_passes
</span><span
class=
"o"
>
=
</span><span
class=
"mi"
>
100
</span><span
class=
"p"
>
)
</span>
</pre></div>
</td></tr></table></div>
<p>
使用以上训练好的模型进行预测,取其中一个模型params_pass_90.tar,输入需要预测的向量组,然后打印输出:
</p>
<div
class=
"highlight-default"
><table
class=
"highlighttable"
><tr><td
class=
"linenos"
><div
class=
"linenodiv"
><pre>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></div></td><td
class=
"code"
><div
class=
"highlight"
><pre><span></span><span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
paddle.v2
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
paddle
</span>
<span
class=
"kn"
>
import
</span>
<span
class=
"nn"
>
numpy
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"nn"
>
np
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
init
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
use_gpu
</span><span
class=
"o"
>
=
</span><span
class=
"kc"
>
False
</span><span
class=
"p"
>
)
</span>
<span
class=
"n"
>
x
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
layer
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
data
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
name
</span><span
class=
"o"
>
=
</span><span
class=
"s1"
>
'
x
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"nb"
>
type
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
data_type
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
dense_vector
</span><span
class=
"p"
>
(
</span><span
class=
"mi"
>
2
</span><span
class=
"p"
>
))
</span>
<span
class=
"n"
>
y_predict
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
layer
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
fc
</span><span
class=
"p"
>
(
</span><span
class=
"nb"
>
input
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
x
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
size
</span><span
class=
"o"
>
=
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
act
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
activation
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
Linear
</span><span
class=
"p"
>
())
</span>
<span
class=
"c1"
>
# loading the model which generated by training
</span>
<span
class=
"k"
>
with
</span>
<span
class=
"nb"
>
open
</span><span
class=
"p"
>
(
</span><span
class=
"s1"
>
'
params_pass_90.tar
'
</span><span
class=
"p"
>
,
</span>
<span
class=
"s1"
>
'
r
'
</span><span
class=
"p"
>
)
</span>
<span
class=
"k"
>
as
</span>
<span
class=
"n"
>
f
</span><span
class=
"p"
>
:
</span>
<span
class=
"n"
>
parameters
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
parameters
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
Parameters
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
from_tar
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
f
</span><span
class=
"p"
>
)
</span>
<span
class=
"c1"
>
# Input multiple sets of data,Output the infer result in a array.
</span>
<span
class=
"n"
>
i
</span>
<span
class=
"o"
>
=
</span>
<span
class=
"p"
>
[[[
</span><span
class=
"mi"
>
1
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
2
</span><span
class=
"p"
>
]],
</span>
<span
class=
"p"
>
[[
</span><span
class=
"mi"
>
3
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
4
</span><span
class=
"p"
>
]],
</span>
<span
class=
"p"
>
[[
</span><span
class=
"mi"
>
5
</span><span
class=
"p"
>
,
</span>
<span
class=
"mi"
>
6
</span><span
class=
"p"
>
]]]
</span>
<span
class=
"nb"
>
print
</span>
<span
class=
"n"
>
paddle
</span><span
class=
"o"
>
.
</span><span
class=
"n"
>
infer
</span><span
class=
"p"
>
(
</span><span
class=
"n"
>
output_layer
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
y_predict
</span><span
class=
"p"
>
,
</span>
<span
class=
"n"
>
parameters
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
parameters
</span><span
class=
"p"
>
,
</span>
<span
class=
"nb"
>
input
</span><span
class=
"o"
>
=
</span><span
class=
"n"
>
i
</span><span
class=
"p"
>
)
</span>
<span
class=
"c1"
>
# Will print:
</span>
<span
class=
"c1"
>
# [[ -3.24491572]
</span>
<span
class=
"c1"
>
# [ -6.94668722]
</span>
<span
class=
"c1"
>
# [-10.64845848]]
</span>
</pre></div>
</td></tr></table></div>
<p>
有关线性回归的实际应用,可以参考PaddlePaddle book的
<a
class=
"reference external"
href=
"http://book.paddlepaddle.org/index.html"
>
第一章节
</a>
。
</p>
</div>
</div>
...
...
develop/doc_cn/searchindex.js
浏览文件 @
b03aadf1
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录