Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
11609762
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看板
提交
11609762
编写于
4月 03, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add event_handler_plot for 03.image_classification
上级
d6497f9d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
120 addition
and
4 deletion
+120
-4
02.recognize_digits/README.en.md
02.recognize_digits/README.en.md
+1
-0
02.recognize_digits/index.en.html
02.recognize_digits/index.en.html
+1
-0
03.image_classification/README.en.md
03.image_classification/README.en.md
+29
-1
03.image_classification/README.md
03.image_classification/README.md
+30
-1
03.image_classification/image/train_and_test.png
03.image_classification/image/train_and_test.png
+0
-0
03.image_classification/index.en.html
03.image_classification/index.en.html
+29
-1
03.image_classification/index.html
03.image_classification/index.html
+30
-1
未找到文件。
02.recognize_digits/README.en.md
浏览文件 @
11609762
...
@@ -259,6 +259,7 @@ def event_handler_plot(event):
...
@@ -259,6 +259,7 @@ def event_handler_plot(event):
```
```
`event_handler`
is used to plot some text data when training.
`event_handler`
is used to plot some text data when training.
```
python
```
python
lists
=
[]
lists
=
[]
...
...
02.recognize_digits/index.en.html
浏览文件 @
11609762
...
@@ -301,6 +301,7 @@ def event_handler_plot(event):
...
@@ -301,6 +301,7 @@ def event_handler_plot(event):
```
```
`event_handler` is used to plot some text data when training.
`event_handler` is used to plot some text data when training.
```python
```python
lists = []
lists = []
...
...
03.image_classification/README.en.md
浏览文件 @
11609762
...
@@ -397,6 +397,34 @@ feeding={'image': 0,
...
@@ -397,6 +397,34 @@ feeding={'image': 0,
Callback function
`event_handler`
will be called during training when a pre-defined event happens.
Callback function
`event_handler`
will be called during training when a pre-defined event happens.
`event_handler_plot`
is used to plot a figure like below:
![
png
](
./image/train_and_test.png
)
```
python
from
paddle.v2.plot
import
Ploter
train_title
=
"Train cost"
test_title
=
"Test cost"
cost_ploter
=
Ploter
(
train_title
,
test_title
)
step
=
0
def
event_handler_plot
(
event
):
global
step
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
step
%
1
==
0
:
cost_ploter
.
append
(
train_title
,
step
,
event
.
cost
)
cost_ploter
.
plot
()
step
+=
1
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
cifar
.
test10
(),
batch_size
=
128
),
feeding
=
feeding
)
cost_ploter
.
append
(
test_title
,
step
,
result
.
cost
)
```
`event_handler`
is used to plot some text data when training.
```
python
```
python
# event handler to track training and testing process
# event handler to track training and testing process
...
@@ -422,7 +450,7 @@ Finally, we can invoke `trainer.train` to start training:
...
@@ -422,7 +450,7 @@ Finally, we can invoke `trainer.train` to start training:
trainer
.
train
(
trainer
.
train
(
reader
=
reader
,
reader
=
reader
,
num_passes
=
200
,
num_passes
=
200
,
event_handler
=
event_handler
,
event_handler
=
event_handler
_plot
,
feeding
=
feeding
)
feeding
=
feeding
)
```
```
...
...
03.image_classification/README.md
浏览文件 @
11609762
...
@@ -389,6 +389,35 @@ feeding={'image': 0,
...
@@ -389,6 +389,35 @@ feeding={'image': 0,
可以使用
`event_handler`
回调函数来观察训练过程,或进行测试等, 该回调函数是
`trainer.train`
函数里设定。
可以使用
`event_handler`
回调函数来观察训练过程,或进行测试等, 该回调函数是
`trainer.train`
函数里设定。
`event_handler_plot`
可以用来利用回调数据来打点画图:
![
png
](
./image/train_and_test.png
)
```
python
from
paddle.v2.plot
import
Ploter
train_title
=
"Train cost"
test_title
=
"Test cost"
cost_ploter
=
Ploter
(
train_title
,
test_title
)
step
=
0
def
event_handler_plot
(
event
):
global
step
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
step
%
1
==
0
:
cost_ploter
.
append
(
train_title
,
step
,
event
.
cost
)
cost_ploter
.
plot
()
step
+=
1
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
cifar
.
test10
(),
batch_size
=
128
),
feeding
=
feeding
)
cost_ploter
.
append
(
test_title
,
step
,
result
.
cost
)
```
`event_handler`
用来在训练过程中输出文本日志
```
python
```
python
# End batch and end pass event handler
# End batch and end pass event handler
def
event_handler
(
event
):
def
event_handler
(
event
):
...
@@ -413,7 +442,7 @@ def event_handler(event):
...
@@ -413,7 +442,7 @@ def event_handler(event):
trainer
.
train
(
trainer
.
train
(
reader
=
reader
,
reader
=
reader
,
num_passes
=
200
,
num_passes
=
200
,
event_handler
=
event_handler
,
event_handler
=
event_handler
_plot
,
feeding
=
feeding
)
feeding
=
feeding
)
```
```
...
...
03.image_classification/image/train_and_test.png
0 → 100644
浏览文件 @
11609762
14.7 KB
03.image_classification/index.en.html
浏览文件 @
11609762
...
@@ -439,6 +439,34 @@ feeding={'image': 0,
...
@@ -439,6 +439,34 @@ feeding={'image': 0,
Callback function `event_handler` will be called during training when a pre-defined event happens.
Callback function `event_handler` will be called during training when a pre-defined event happens.
`event_handler_plot`is used to plot a figure like below:
![png](./image/train_and_test.png)
```python
from paddle.v2.plot import Ploter
train_title = "Train cost"
test_title = "Test cost"
cost_ploter = Ploter(train_title, test_title)
step = 0
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 1 == 0:
cost_ploter.append(train_title, step, event.cost)
cost_ploter.plot()
step += 1
if isinstance(event, paddle.event.EndPass):
result = trainer.test(
reader=paddle.batch(
paddle.dataset.cifar.test10(), batch_size=128),
feeding=feeding)
cost_ploter.append(test_title, step, result.cost)
```
`event_handler` is used to plot some text data when training.
```python
```python
# event handler to track training and testing process
# event handler to track training and testing process
...
@@ -464,7 +492,7 @@ Finally, we can invoke `trainer.train` to start training:
...
@@ -464,7 +492,7 @@ Finally, we can invoke `trainer.train` to start training:
trainer.train(
trainer.train(
reader=reader,
reader=reader,
num_passes=200,
num_passes=200,
event_handler=event_handler,
event_handler=event_handler
_plot
,
feeding=feeding)
feeding=feeding)
```
```
...
...
03.image_classification/index.html
浏览文件 @
11609762
...
@@ -431,6 +431,35 @@ feeding={'image': 0,
...
@@ -431,6 +431,35 @@ feeding={'image': 0,
可以使用`event_handler`回调函数来观察训练过程,或进行测试等, 该回调函数是`trainer.train`函数里设定。
可以使用`event_handler`回调函数来观察训练过程,或进行测试等, 该回调函数是`trainer.train`函数里设定。
`event_handler_plot`可以用来利用回调数据来打点画图:
![png](./image/train_and_test.png)
```python
from paddle.v2.plot import Ploter
train_title = "Train cost"
test_title = "Test cost"
cost_ploter = Ploter(train_title, test_title)
step = 0
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 1 == 0:
cost_ploter.append(train_title, step, event.cost)
cost_ploter.plot()
step += 1
if isinstance(event, paddle.event.EndPass):
result = trainer.test(
reader=paddle.batch(
paddle.dataset.cifar.test10(), batch_size=128),
feeding=feeding)
cost_ploter.append(test_title, step, result.cost)
```
`event_handler` 用来在训练过程中输出文本日志
```python
```python
# End batch and end pass event handler
# End batch and end pass event handler
def event_handler(event):
def event_handler(event):
...
@@ -455,7 +484,7 @@ def event_handler(event):
...
@@ -455,7 +484,7 @@ def event_handler(event):
trainer.train(
trainer.train(
reader=reader,
reader=reader,
num_passes=200,
num_passes=200,
event_handler=event_handler,
event_handler=event_handler
_plot
,
feeding=feeding)
feeding=feeding)
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录