提交 6d8aade8 编写于 作者: L lujun

ses-3,fix review for pr-646,update ploter,test=develop

上级 c8857716
...@@ -412,11 +412,11 @@ def train_test(program, reader): ...@@ -412,11 +412,11 @@ def train_test(program, reader):
```python ```python
params_dirname = "image_classification_resnet.inference.model" params_dirname = "image_classification_resnet.inference.model"
from paddle.v2.plot import Ploter from paddle.utils.plot import Ploter
train_title = "Train cost" train_prompt = "Train cost"
test_title = "Test cost" test_prompt = "Test cost"
plot_cost = Ploter(test_title,train_title) plot_cost = Ploter(test_prompt,train_prompt)
# main train loop. # main train loop.
def train_loop(): def train_loop():
...@@ -434,13 +434,13 @@ def train_loop(): ...@@ -434,13 +434,13 @@ def train_loop():
feed=feeder.feed(data_train), feed=feeder.feed(data_train),
fetch_list=[avg_cost, acc]) fetch_list=[avg_cost, acc])
if step % 1 == 0: if step % 1 == 0:
plot_cost.append(train_title, step, avg_loss_value[0]) plot_cost.append(train_prompt, step, avg_loss_value[0])
plot_cost.plot() plot_cost.plot()
step += 1 step += 1
avg_cost_test, accuracy_test = train_test(test_program, avg_cost_test, accuracy_test = train_test(test_program,
reader=test_reader) reader=test_reader)
plot_cost.append(test_title, step, avg_cost_test) plot_cost.append(test_prompt, step, avg_cost_test)
# save parameters # save parameters
if params_dirname is not None: if params_dirname is not None:
...@@ -485,23 +485,18 @@ Test with Pass 0, Loss 1.1, Acc 0.6 ...@@ -485,23 +485,18 @@ Test with Pass 0, Loss 1.1, Acc 0.6
### 生成预测输入数据 ### 生成预测输入数据
`dog.png` is an example image of a dog. Turn it into an numpy array to match the data feeder format. `dog.png` 是一张小狗的图片. 我们将它转换成 `numpy` 数组以满足`feeder`的格式.
### 生成预测输入数据
`dog.png` is an example image of a dog. Turn it into an numpy array to match the data feeder format.
```python ```python
# Prepare testing data. # Prepare testing data.
from PIL import Image from PIL import Image
import numpy as np
import os import os
def load_image(file): def load_image(file):
im = Image.open(file) im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS) im = im.resize((32, 32), Image.ANTIALIAS)
im = np.array(im).astype(np.float32) im = numpy.array(im).astype(numpy.float32)
# The storage order of the loaded image is W(width), # The storage order of the loaded image is W(width),
# H(height), C(channel). PaddlePaddle requires # H(height), C(channel). PaddlePaddle requires
# the CHW order, so transpose them. # the CHW order, so transpose them.
......
...@@ -454,11 +454,11 @@ def train_test(program, reader): ...@@ -454,11 +454,11 @@ def train_test(program, reader):
```python ```python
params_dirname = "image_classification_resnet.inference.model" params_dirname = "image_classification_resnet.inference.model"
from paddle.v2.plot import Ploter from paddle.utils.plot import Ploter
train_title = "Train cost" train_prompt = "Train cost"
test_title = "Test cost" test_prompt = "Test cost"
plot_cost = Ploter(test_title,train_title) plot_cost = Ploter(test_prompt,train_prompt)
# main train loop. # main train loop.
def train_loop(): def train_loop():
...@@ -476,13 +476,13 @@ def train_loop(): ...@@ -476,13 +476,13 @@ def train_loop():
feed=feeder.feed(data_train), feed=feeder.feed(data_train),
fetch_list=[avg_cost, acc]) fetch_list=[avg_cost, acc])
if step % 1 == 0: if step % 1 == 0:
plot_cost.append(train_title, step, avg_loss_value[0]) plot_cost.append(train_prompt, step, avg_loss_value[0])
plot_cost.plot() plot_cost.plot()
step += 1 step += 1
avg_cost_test, accuracy_test = train_test(test_program, avg_cost_test, accuracy_test = train_test(test_program,
reader=test_reader) reader=test_reader)
plot_cost.append(test_title, step, avg_cost_test) plot_cost.append(test_prompt, step, avg_cost_test)
# save parameters # save parameters
if params_dirname is not None: if params_dirname is not None:
...@@ -527,23 +527,18 @@ Test with Pass 0, Loss 1.1, Acc 0.6 ...@@ -527,23 +527,18 @@ Test with Pass 0, Loss 1.1, Acc 0.6
### 生成预测输入数据 ### 生成预测输入数据
`dog.png` is an example image of a dog. Turn it into an numpy array to match the data feeder format. `dog.png` 是一张小狗的图片. 我们将它转换成 `numpy` 数组以满足`feeder`的格式.
### 生成预测输入数据
`dog.png` is an example image of a dog. Turn it into an numpy array to match the data feeder format.
```python ```python
# Prepare testing data. # Prepare testing data.
from PIL import Image from PIL import Image
import numpy as np
import os import os
def load_image(file): def load_image(file):
im = Image.open(file) im = Image.open(file)
im = im.resize((32, 32), Image.ANTIALIAS) im = im.resize((32, 32), Image.ANTIALIAS)
im = np.array(im).astype(np.float32) im = numpy.array(im).astype(numpy.float32)
# The storage order of the loaded image is W(width), # The storage order of the loaded image is W(width),
# H(height), C(channel). PaddlePaddle requires # H(height), C(channel). PaddlePaddle requires
# the CHW order, so transpose them. # the CHW order, so transpose them.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册