提交 f635d2e1 编写于 作者: J JiabinYang

fix the minus inference result problem

上级 7079f1bf
...@@ -251,12 +251,20 @@ inferencer = fluid.Inferencer( ...@@ -251,12 +251,20 @@ inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
batch_size = 10 batch_size = 10
tensor_x = numpy.random.uniform(0, 10, [batch_size, 13]).astype("float32") test_reader = paddle.batch(paddle.dataset.uci_housing.test(),batch_size=batch_size)
test_data = test_reader().next()
test_feat = numpy.array([data[0] for data in test_data]).astype("float32")
test_label = numpy.array([data[1] for data in test_data]).astype("float32")
results = inferencer.infer({'x': test_feat})
results = inferencer.infer({'x': tensor_x})
print("infer results: (House Price)") print("infer results: (House Price)")
for k in range(0, batch_size-1): for k in range(0, batch_size-1):
print("%d. %f" % (k, results[0][k])) print("%d. %f" % (k, results[0][k]))
print("\nground truth:")
for k in range(0, batch_size-1):
print("%d. %f" % (k, test_label[k]))
``` ```
## 总结 ## 总结
......
...@@ -293,12 +293,20 @@ inferencer = fluid.Inferencer( ...@@ -293,12 +293,20 @@ inferencer = fluid.Inferencer(
infer_func=inference_program, param_path=params_dirname, place=place) infer_func=inference_program, param_path=params_dirname, place=place)
batch_size = 10 batch_size = 10
tensor_x = numpy.random.uniform(0, 10, [batch_size, 13]).astype("float32") test_reader = paddle.batch(paddle.dataset.uci_housing.test(),batch_size=batch_size)
test_data = test_reader().next()
test_feat = numpy.array([data[0] for data in test_data]).astype("float32")
test_label = numpy.array([data[1] for data in test_data]).astype("float32")
results = inferencer.infer({'x': test_feat})
results = inferencer.infer({'x': tensor_x})
print("infer results: (House Price)") print("infer results: (House Price)")
for k in range(0, batch_size-1): for k in range(0, batch_size-1):
print("%d. %f" % (k, results[0][k])) print("%d. %f" % (k, results[0][k]))
print("\nground truth:")
for k in range(0, batch_size-1):
print("%d. %f" % (k, test_label[k]))
``` ```
## 总结 ## 总结
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册