Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
288484b1
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看板
提交
288484b1
编写于
4月 24, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add htmls
上级
0a404b9c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
8 deletion
+77
-8
.tools/build_docker.sh
.tools/build_docker.sh
+1
-0
01.fit_a_line/README.en.md
01.fit_a_line/README.en.md
+19
-2
01.fit_a_line/README.md
01.fit_a_line/README.md
+19
-2
01.fit_a_line/index.en.html
01.fit_a_line/index.en.html
+19
-2
01.fit_a_line/index.html
01.fit_a_line/index.html
+19
-2
未找到文件。
.tools/build_docker.sh
浏览文件 @
288484b1
...
@@ -67,6 +67,7 @@ RUN ${update_mirror_cmd}
...
@@ -67,6 +67,7 @@ RUN ${update_mirror_cmd}
apt-get -y install gcc &&
\
apt-get -y install gcc &&
\
apt-get -y clean &&
\
apt-get -y clean &&
\
localedef -f UTF-8 -i en_US en_US.UTF-8 &&
\
localedef -f UTF-8 -i en_US en_US.UTF-8 &&
\
pip install --upgrade pip &&
\
pip install -U pillow matplotlib jupyter numpy requests scipy
pip install -U pillow matplotlib jupyter numpy requests scipy
#convert md to ipynb
#convert md to ipynb
...
...
01.fit_a_line/README.en.md
浏览文件 @
288484b1
...
@@ -162,6 +162,23 @@ feeding={'x': 0, 'y': 1}
...
@@ -162,6 +162,23 @@ feeding={'x': 0, 'y': 1}
Moreover, an event handler is provided to print the training progress:
Moreover, an event handler is provided to print the training progress:
```
python
lists
=
[]
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
100
==
0
:
print
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
print
"Test with Pass %d, Cost %f, %s
\n
"
%
(
event
.
pass_id
,
result
.
cost
,
result
.
metrics
)
lists
.
append
((
event
.
pass_id
,
result
.
cost
,
result
.
metrics
[
'classification_error_evaluator'
]))
```
```
python
```
python
# event_handler to print training and testing info
# event_handler to print training and testing info
from
paddle.v2.plot
import
Ploter
from
paddle.v2.plot
import
Ploter
...
@@ -172,7 +189,7 @@ plot_cost = Ploter(train_title, test_title)
...
@@ -172,7 +189,7 @@ plot_cost = Ploter(train_title, test_title)
step
=
0
step
=
0
def
event_handler
(
event
):
def
event_handler
_plot
(
event
):
global
step
global
step
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
step
%
10
==
0
:
# every 10 batches, record a train cost
if
step
%
10
==
0
:
# every 10 batches, record a train cost
...
@@ -200,7 +217,7 @@ trainer.train(
...
@@ -200,7 +217,7 @@ trainer.train(
uci_housing
.
train
(),
buf_size
=
500
),
uci_housing
.
train
(),
buf_size
=
500
),
batch_size
=
2
),
batch_size
=
2
),
feeding
=
feeding
,
feeding
=
feeding
,
event_handler
=
event_handler
,
event_handler
=
event_handler
_plot
,
num_passes
=
30
)
num_passes
=
30
)
```
```
...
...
01.fit_a_line/README.md
浏览文件 @
288484b1
...
@@ -157,6 +157,23 @@ feeding={'x': 0, 'y': 1}
...
@@ -157,6 +157,23 @@ feeding={'x': 0, 'y': 1}
此外,我们还可以提供一个 event handler,来打印训练的进度:
此外,我们还可以提供一个 event handler,来打印训练的进度:
```
python
lists
=
[]
def
event_handler
(
event
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
event
.
batch_id
%
100
==
0
:
print
"Pass %d, Batch %d, Cost %f, %s"
%
(
event
.
pass_id
,
event
.
batch_id
,
event
.
cost
,
event
.
metrics
)
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
mnist
.
test
(),
batch_size
=
128
))
print
"Test with Pass %d, Cost %f, %s
\n
"
%
(
event
.
pass_id
,
result
.
cost
,
result
.
metrics
)
lists
.
append
((
event
.
pass_id
,
result
.
cost
,
result
.
metrics
[
'classification_error_evaluator'
]))
```
```
python
```
python
# event_handler to print training and testing info
# event_handler to print training and testing info
from
paddle.v2.plot
import
Ploter
from
paddle.v2.plot
import
Ploter
...
@@ -167,7 +184,7 @@ cost_ploter = Ploter(train_title, test_title)
...
@@ -167,7 +184,7 @@ cost_ploter = Ploter(train_title, test_title)
step
=
0
step
=
0
def
event_handler
(
event
):
def
event_handler
_plot
(
event
):
global
step
global
step
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
isinstance
(
event
,
paddle
.
event
.
EndIteration
):
if
step
%
10
==
0
:
# every 10 batches, record a train cost
if
step
%
10
==
0
:
# every 10 batches, record a train cost
...
@@ -195,7 +212,7 @@ trainer.train(
...
@@ -195,7 +212,7 @@ trainer.train(
uci_housing
.
train
(),
buf_size
=
500
),
uci_housing
.
train
(),
buf_size
=
500
),
batch_size
=
2
),
batch_size
=
2
),
feeding
=
feeding
,
feeding
=
feeding
,
event_handler
=
event_handler
,
event_handler
=
event_handler
_plot
,
num_passes
=
30
)
num_passes
=
30
)
```
```
...
...
01.fit_a_line/index.en.html
浏览文件 @
288484b1
...
@@ -204,6 +204,23 @@ feeding={'x': 0, 'y': 1}
...
@@ -204,6 +204,23 @@ feeding={'x': 0, 'y': 1}
Moreover, an event handler is provided to print the training progress:
Moreover, an event handler is provided to print the training progress:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
```python
# event_handler to print training and testing info
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
from paddle.v2.plot import Ploter
...
@@ -214,7 +231,7 @@ plot_cost = Ploter(train_title, test_title)
...
@@ -214,7 +231,7 @@ plot_cost = Ploter(train_title, test_title)
step = 0
step = 0
def event_handler(event):
def event_handler
_plot
(event):
global step
global step
if isinstance(event, paddle.event.EndIteration):
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
if step % 10 == 0: # every 10 batches, record a train cost
...
@@ -242,7 +259,7 @@ trainer.train(
...
@@ -242,7 +259,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
uci_housing.train(), buf_size=500),
batch_size=2),
batch_size=2),
feeding=feeding,
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler
_plot
,
num_passes=30)
num_passes=30)
```
```
...
...
01.fit_a_line/index.html
浏览文件 @
288484b1
...
@@ -199,6 +199,23 @@ feeding={'x': 0, 'y': 1}
...
@@ -199,6 +199,23 @@ feeding={'x': 0, 'y': 1}
此外,我们还可以提供一个 event handler,来打印训练的进度:
此外,我们还可以提供一个 event handler,来打印训练的进度:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
```python
# event_handler to print training and testing info
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
from paddle.v2.plot import Ploter
...
@@ -209,7 +226,7 @@ cost_ploter = Ploter(train_title, test_title)
...
@@ -209,7 +226,7 @@ cost_ploter = Ploter(train_title, test_title)
step = 0
step = 0
def event_handler(event):
def event_handler
_plot
(event):
global step
global step
if isinstance(event, paddle.event.EndIteration):
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
if step % 10 == 0: # every 10 batches, record a train cost
...
@@ -237,7 +254,7 @@ trainer.train(
...
@@ -237,7 +254,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
uci_housing.train(), buf_size=500),
batch_size=2),
batch_size=2),
feeding=feeding,
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler
_plot
,
num_passes=30)
num_passes=30)
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录