diff --git a/01.fit_a_line/README.cn.md b/01.fit_a_line/README.cn.md index e554770ef4563f8e907197a33c030ed8d73fa871..c8ef2ea43adf521c5196d06d289000d8789ebbdf 100644 --- a/01.fit_a_line/README.cn.md +++ b/01.fit_a_line/README.cn.md @@ -251,12 +251,20 @@ inferencer = fluid.Inferencer( infer_func=inference_program, param_path=params_dirname, place=place) 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)") for k in range(0, batch_size-1): 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])) ``` ## 总结 diff --git a/01.fit_a_line/index.cn.html b/01.fit_a_line/index.cn.html index db738d951599345746184796b25013d82037e0b5..4ccb632da6de467fd1592aaa6728c397c99c5d73 100644 --- a/01.fit_a_line/index.cn.html +++ b/01.fit_a_line/index.cn.html @@ -293,12 +293,20 @@ inferencer = fluid.Inferencer( infer_func=inference_program, param_path=params_dirname, place=place) 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)") for k in range(0, batch_size-1): 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])) ``` ## 总结