Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
book
提交
ea03d59e
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看板
提交
ea03d59e
编写于
4月 05, 2017
作者:
Q
qingqing01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test in jupyter notebook
上级
92d9d2d2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
19 deletion
+25
-19
03.image_classification/README.en.md
03.image_classification/README.en.md
+6
-5
03.image_classification/README.md
03.image_classification/README.md
+6
-4
03.image_classification/index.en.html
03.image_classification/index.en.html
+6
-5
03.image_classification/index.html
03.image_classification/index.html
+6
-4
03.image_classification/train.py
03.image_classification/train.py
+1
-1
未找到文件。
03.image_classification/README.en.md
浏览文件 @
ea03d59e
...
...
@@ -169,6 +169,7 @@ We must import and initialize PaddlePaddle (enable/disable GPU, set the number o
```
python
import
sys
import
gzip
import
paddle.v2
as
paddle
from
vgg
import
vgg_bn_drop
from
resnet
import
resnet_cifar10
...
...
@@ -417,10 +418,6 @@ def event_handler_plot(event):
cost_ploter
.
plot
()
step
+=
1
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
gzip
.
open
(
'params_pass_%d.tar.gz'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
cifar
.
test10
(),
batch_size
=
128
),
...
...
@@ -441,6 +438,10 @@ def event_handler(event):
sys
.
stdout
.
write
(
'.'
)
sys
.
stdout
.
flush
()
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
gzip
.
open
(
'params_pass_%d.tar.gz'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
cifar
.
test10
(),
batch_size
=
128
),
...
...
@@ -499,7 +500,7 @@ test_data.append((load_image('image/dog.png'),))
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
lab
=
np
.
argsort
(
-
probs
)
# probs and lab are the results of one batch data
print
(
"Label of image/dog.png is: %d"
,
lab
[
0
][
0
])
print
"Label of image/dog.png is: %d"
%
lab
[
0
][
0
]
```
...
...
03.image_classification/README.md
浏览文件 @
ea03d59e
...
...
@@ -156,6 +156,7 @@ Paddle API提供了自动加载cifar数据集模块 `paddle.dataset.cifar`。
```
python
import
sys
import
gzip
import
paddle.v2
as
paddle
from
vgg
import
vgg_bn_drop
from
resnet
import
resnet_cifar10
...
...
@@ -409,9 +410,6 @@ def event_handler_plot(event):
cost_ploter
.
plot
()
step
+=
1
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
gzip
.
open
(
'params_pass_%d.tar.gz'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
...
...
@@ -433,6 +431,10 @@ def event_handler(event):
sys
.
stdout
.
write
(
'.'
)
sys
.
stdout
.
flush
()
if
isinstance
(
event
,
paddle
.
event
.
EndPass
):
# save parameters
with
gzip
.
open
(
'params_pass_%d.tar.gz'
%
event
.
pass_id
,
'w'
)
as
f
:
parameters
.
to_tar
(
f
)
result
=
trainer
.
test
(
reader
=
paddle
.
batch
(
paddle
.
dataset
.
cifar
.
test10
(),
batch_size
=
128
),
...
...
@@ -490,7 +492,7 @@ test_data.append((load_image('image/dog.png'),))
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
lab
=
np
.
argsort
(
-
probs
)
# probs and lab are the results of one batch data
print
(
"Label of image/dog.png is: %d"
,
lab
[
0
][
0
])
print
"Label of image/dog.png is: %d"
%
lab
[
0
][
0
]
```
...
...
03.image_classification/index.en.html
浏览文件 @
ea03d59e
...
...
@@ -211,6 +211,7 @@ We must import and initialize PaddlePaddle (enable/disable GPU, set the number o
```python
import sys
import gzip
import paddle.v2 as paddle
from vgg import vgg_bn_drop
from resnet import resnet_cifar10
...
...
@@ -459,10 +460,6 @@ def event_handler_plot(event):
cost_ploter.plot()
step += 1
if isinstance(event, paddle.event.EndPass):
# save parameters
with gzip.open('params_pass_%d.tar.gz' % event.pass_id, 'w') as f:
parameters.to_tar(f)
result = trainer.test(
reader=paddle.batch(
paddle.dataset.cifar.test10(), batch_size=128),
...
...
@@ -483,6 +480,10 @@ def event_handler(event):
sys.stdout.write('.')
sys.stdout.flush()
if isinstance(event, paddle.event.EndPass):
# save parameters
with gzip.open('params_pass_%d.tar.gz' % event.pass_id, 'w') as f:
parameters.to_tar(f)
result = trainer.test(
reader=paddle.batch(
paddle.dataset.cifar.test10(), batch_size=128),
...
...
@@ -541,7 +542,7 @@ test_data.append((load_image('image/dog.png'),))
probs = paddle.infer(
output_layer=out, parameters=parameters, input=test_data)
lab = np.argsort(-probs) # probs and lab are the results of one batch data
print
("Label of image/dog.png is: %d", lab[0][0])
print
"Label of image/dog.png is: %d" % lab[0][0]
```
...
...
03.image_classification/index.html
浏览文件 @
ea03d59e
...
...
@@ -198,6 +198,7 @@ Paddle API提供了自动加载cifar数据集模块 `paddle.dataset.cifar`。
```python
import sys
import gzip
import paddle.v2 as paddle
from vgg import vgg_bn_drop
from resnet import resnet_cifar10
...
...
@@ -451,9 +452,6 @@ def event_handler_plot(event):
cost_ploter.plot()
step += 1
if isinstance(event, paddle.event.EndPass):
# save parameters
with gzip.open('params_pass_%d.tar.gz' % event.pass_id, 'w') as f:
parameters.to_tar(f)
result = trainer.test(
reader=paddle.batch(
...
...
@@ -475,6 +473,10 @@ def event_handler(event):
sys.stdout.write('.')
sys.stdout.flush()
if isinstance(event, paddle.event.EndPass):
# save parameters
with gzip.open('params_pass_%d.tar.gz' % event.pass_id, 'w') as f:
parameters.to_tar(f)
result = trainer.test(
reader=paddle.batch(
paddle.dataset.cifar.test10(), batch_size=128),
...
...
@@ -532,7 +534,7 @@ test_data.append((load_image('image/dog.png'),))
probs = paddle.infer(
output_layer=out, parameters=parameters, input=test_data)
lab = np.argsort(-probs) # probs and lab are the results of one batch data
print
("Label of image/dog.png is: %d", lab[0][0])
print
"Label of image/dog.png is: %d" % lab[0][0]
```
...
...
03.image_classification/train.py
浏览文件 @
ea03d59e
...
...
@@ -108,7 +108,7 @@ def main():
probs
=
paddle
.
infer
(
output_layer
=
out
,
parameters
=
parameters
,
input
=
test_data
)
lab
=
np
.
argsort
(
-
probs
)
# probs and lab are the results of one batch data
print
(
"Label of image/dog.png is: %d"
,
lab
[
0
][
0
])
print
"Label of image/dog.png is: %d"
%
lab
[
0
][
0
]
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录