Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
90988fbe
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看板
提交
90988fbe
编写于
7月 14, 2018
作者:
J
JiabinYang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "refine the comments and the inference result format"
This reverts commit
7079f1bf
.
上级
5829bd37
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
8 addition
and
12 deletion
+8
-12
01.fit_a_line/README.cn.md
01.fit_a_line/README.cn.md
+4
-6
01.fit_a_line/image/ranges.png
01.fit_a_line/image/ranges.png
+0
-0
01.fit_a_line/index.cn.html
01.fit_a_line/index.cn.html
+4
-6
未找到文件。
01.fit_a_line/README.cn.md
浏览文件 @
90988fbe
...
@@ -179,7 +179,7 @@ feed_order=['x', 'y']
...
@@ -179,7 +179,7 @@ feed_order=['x', 'y']
除此之外,可以定义一个事件相应器来处理类似
`打印训练进程`
的事件:
除此之外,可以定义一个事件相应器来处理类似
`打印训练进程`
的事件:
```
python
```
python
# Specify the directory to save the parameters
# Specify the directory
path
to save the parameters
params_dirname
=
"fit_a_line.inference.model"
params_dirname
=
"fit_a_line.inference.model"
# Plot data
# Plot data
...
@@ -190,11 +190,11 @@ plot_cost = Ploter(train_title, test_title)
...
@@ -190,11 +190,11 @@ plot_cost = Ploter(train_title, test_title)
step
=
0
step
=
0
# event_handler
prints
training and testing info
# event_handler
to print
training and testing info
def
event_handler_plot
(
event
):
def
event_handler_plot
(
event
):
global
step
global
step
if
isinstance
(
event
,
fluid
.
EndStepEvent
):
if
isinstance
(
event
,
fluid
.
EndStepEvent
):
if
event
.
step
%
10
==
0
:
#
record the test cost every 10 seconds
if
event
.
step
%
10
==
0
:
#
every 10 batches, record a test cost
test_metrics
=
trainer
.
test
(
test_metrics
=
trainer
.
test
(
reader
=
test_reader
,
feed_order
=
feed_order
)
reader
=
test_reader
,
feed_order
=
feed_order
)
...
@@ -254,9 +254,7 @@ batch_size = 10
...
@@ -254,9 +254,7 @@ batch_size = 10
tensor_x
=
numpy
.
random
.
uniform
(
0
,
10
,
[
batch_size
,
13
]).
astype
(
"float32"
)
tensor_x
=
numpy
.
random
.
uniform
(
0
,
10
,
[
batch_size
,
13
]).
astype
(
"float32"
)
results
=
inferencer
.
infer
({
'x'
:
tensor_x
})
results
=
inferencer
.
infer
({
'x'
:
tensor_x
})
print
(
"infer results: (House Price)"
)
print
(
"infer results: "
,
results
[
0
])
for
k
in
range
(
0
,
batch_size
-
1
):
print
(
"%d. %f"
%
(
k
,
results
[
0
][
k
]))
```
```
## 总结
## 总结
...
...
01.fit_a_line/image/ranges.png
查看替换文件 @
5829bd37
浏览文件 @
90988fbe
6.6 KB
|
W:
|
H:
6.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
01.fit_a_line/index.cn.html
浏览文件 @
90988fbe
...
@@ -221,7 +221,7 @@ feed_order=['x', 'y']
...
@@ -221,7 +221,7 @@ feed_order=['x', 'y']
除此之外,可以定义一个事件相应器来处理类似`打印训练进程`的事件:
除此之外,可以定义一个事件相应器来处理类似`打印训练进程`的事件:
```python
```python
# Specify the directory to save the parameters
# Specify the directory
path
to save the parameters
params_dirname = "fit_a_line.inference.model"
params_dirname = "fit_a_line.inference.model"
# Plot data
# Plot data
...
@@ -232,11 +232,11 @@ plot_cost = Ploter(train_title, test_title)
...
@@ -232,11 +232,11 @@ plot_cost = Ploter(train_title, test_title)
step = 0
step = 0
# event_handler
prints
training and testing info
# event_handler
to print
training and testing info
def event_handler_plot(event):
def event_handler_plot(event):
global step
global step
if isinstance(event, fluid.EndStepEvent):
if isinstance(event, fluid.EndStepEvent):
if event.step % 10 == 0: #
record the test cost every 10 seconds
if event.step % 10 == 0: #
every 10 batches, record a test cost
test_metrics = trainer.test(
test_metrics = trainer.test(
reader=test_reader, feed_order=feed_order)
reader=test_reader, feed_order=feed_order)
...
@@ -296,9 +296,7 @@ batch_size = 10
...
@@ -296,9 +296,7 @@ batch_size = 10
tensor_x =
numpy.random.uniform(0,
10,
[
batch_size
,
13]).
astype
("
float32
")
tensor_x =
numpy.random.uniform(0,
10,
[
batch_size
,
13]).
astype
("
float32
")
results =
inferencer.infer({'x':
tensor_x
})
results =
inferencer.infer({'x':
tensor_x
})
print
("
infer
results:
(
House
Price
)")
print
("
infer
results:
",
results
[0])
for
k
in
range
(0,
batch_size-1
)
:
print
("%
d.
%
f
"
%
(
k
,
results
[0][
k
]))
```
```
##
总结
##
总结
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录