提交 a4979d20 编写于 作者: J JiabinYang

refine comments and the presentation of inference result for book03

上级 d4414cbb
...@@ -160,6 +160,7 @@ import paddle ...@@ -160,6 +160,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
本教程中我们提供了VGG和ResNet两个模型的配置。 本教程中我们提供了VGG和ResNet两个模型的配置。
...@@ -426,7 +427,7 @@ def event_handler(event): ...@@ -426,7 +427,7 @@ def event_handler(event):
通过`trainer.train`函数训练: 通过`trainer.train`函数训练:
**注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高培训速度。 **注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高训练速度。
```python ```python
trainer.train( trainer.train(
...@@ -499,10 +500,10 @@ img = load_image(cur_dir + '/image/dog.png') ...@@ -499,10 +500,10 @@ img = load_image(cur_dir + '/image/dog.png')
```python ```python
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
## 总结 ## 总结
......
...@@ -202,6 +202,7 @@ import paddle ...@@ -202,6 +202,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
import sys import sys
from __future__ import print_function
``` ```
本教程中我们提供了VGG和ResNet两个模型的配置。 本教程中我们提供了VGG和ResNet两个模型的配置。
...@@ -468,7 +469,7 @@ def event_handler(event): ...@@ -468,7 +469,7 @@ def event_handler(event):
通过`trainer.train`函数训练: 通过`trainer.train`函数训练:
**注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高培训速度。 **注意:** CPU,每个 Epoch 将花费大约15~20分钟。这部分可能需要一段时间。请随意修改代码,在GPU上运行测试,以提高训练速度。
```python ```python
trainer.train( trainer.train(
...@@ -541,10 +542,10 @@ img = load_image(cur_dir + '/image/dog.png') ...@@ -541,10 +542,10 @@ img = load_image(cur_dir + '/image/dog.png')
```python ```python
inferencer = fluid.Inferencer( inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
label_list = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
# inference # inference
results = inferencer.infer({'pixel': img}) results = inferencer.infer({'pixel': img})
print("infer results: ", results) print("infer results: %s" % label_list[np.argmax(results[0])])
``` ```
## 总结 ## 总结
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册