Skip to content

Commit abdd2e0

Browse files
committed
Revert
1 parent 699cfba commit abdd2e0

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

python/paddle/v2/fluid/tests/book/test_image_classification_train.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import paddle.v2.fluid.layers as layers
66
import paddle.v2.fluid.nets as nets
77
import paddle.v2.fluid.evaluator as evaluator
8-
from paddle.v2.fluid.io import get_inference_program
98
from paddle.v2.fluid.executor import Executor
109
from paddle.v2.fluid.initializer import XavierInitializer
1110
from paddle.v2.fluid.optimizer import AdamOptimizer
@@ -117,11 +116,9 @@ def conv_block(input, num_filter, groups, dropouts):
117116

118117
train_reader = paddle.batch(
119118
paddle.reader.shuffle(
120-
paddle.dataset.cifar.train10(), buf_size=BATCH_SIZE * 10),
119+
paddle.dataset.cifar.train10(), buf_size=128 * 10),
121120
batch_size=BATCH_SIZE)
122121

123-
test_reader = paddle.batch(paddle.dataset.cifar.test10(), batch_size=BATCH_SIZE)
124-
125122
place = core.CPUPlace()
126123
exe = Executor(place)
127124

@@ -152,41 +149,10 @@ def conv_block(input, num_filter, groups, dropouts):
152149
loss = np.array(outs[0])
153150
acc = np.array(outs[1])
154151
pass_acc = accuracy.eval(exe)
155-
156-
batch_id = batch_id + 1
157-
158-
test_accuracy, test_acc_out = evaluator.accuracy(
159-
input=predict, label=label)
160-
161-
test_target = [avg_cost, test_acc_out] + test_accuracy.states().values()
162-
inference_program = get_inference_program(test_target)
163-
164-
test_accuracy.reset(exe)
165-
166-
for data in test_reader():
167-
x_data = np.array(map(lambda x: x[0].reshape(data_shape),
168-
data)).astype("float32")
169-
y_data = np.array(map(lambda x: x[1], data)).astype("int64")
170-
y_data = np.expand_dims(y_data, axis=1)
171-
172-
tensor_x = core.LoDTensor()
173-
tensor_x.set(x_data, place)
174-
175-
tensor_y = core.LoDTensor()
176-
tensor_y.set(y_data, place)
177-
178-
outs = exe.run(inference_program,
179-
feed={'pixel': tensor_x,
180-
'label': tensor_y},
181-
fetch_list=[avg_cost, test_acc_out])
182-
out = np.array(outs[0])
183-
acc = np.array(outs[1])
184-
185-
test_pass_acc = test_accuracy.eval(exe)
186-
187152
print("pass_id:" + str(pass_id) + " batch_id:" + str(batch_id) +
188153
" loss:" + str(loss) + " acc:" + str(acc) + " pass_acc:" + str(
189-
pass_acc) + " test_pass_acc:" + str(test_pass_acc))
154+
pass_acc))
155+
batch_id = batch_id + 1
190156

191157
if batch_id > 1:
192158
# this model is slow, so if we can train two mini batch, we think it works properly.

0 commit comments

Comments
 (0)