Skip to content

Commit

Permalink
Merge pull request #11864 from kuke/fix_test_a_line
Browse files Browse the repository at this point in the history
Use real test data for fit_a_line model to get valid result
  • Loading branch information
luotao1 authored Jun 30, 2018
2 parents e2b1c5d + c225d7a commit 06da740
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions python/paddle/fluid/tests/book/test_fit_a_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,23 @@ def infer(use_cuda, save_dirname=None):
# The input's dimension should be 2-D and the second dim is 13
# The input data should be >= 0
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")

assert feed_target_names[0] == 'x'
results = exe.run(inference_program,
feed={feed_target_names[0]: tensor_x},
feed={feed_target_names[0]: numpy.array(test_feat)},
fetch_list=fetch_targets)
print("infer shape: ", results[0].shape)
print("infer results: ", results[0])
print("ground truth: ", test_label)


def main(use_cuda, is_local=True):
Expand Down

0 comments on commit 06da740

Please sign in to comment.