From 56c80e0bbed66cbabb6b6e98a9d0eeb46261010b Mon Sep 17 00:00:00 2001 From: "Wang,Jeff" Date: Tue, 7 Nov 2017 18:59:21 -0800 Subject: [PATCH] adding code --- 01.fit_a_line/infer.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/01.fit_a_line/infer.py b/01.fit_a_line/infer.py index e69de29..e26cf07 100644 --- a/01.fit_a_line/infer.py +++ b/01.fit_a_line/infer.py @@ -0,0 +1,19 @@ +import paddle.v2 as paddle + +# Initialize PaddlePaddle. +paddle.init(use_gpu=False, trainer_count=1) + +# Configure the neural network. +x = paddle.layer.data(name='x', type=paddle.data_type.dense_vector(13)) +y_predict = paddle.layer.fc(input=x, size=1, act=paddle.activation.Linear()) + +with open('fit_a_line.tar', 'r') as f: + parameters = paddle.parameters.Parameters.from_tar(f) + +# Infer using provided test data. +probs = paddle.infer( + output_layer=y_predict, parameters=parameters, + input=[item for item in paddle.dataset.uci_housing.test()()]) + +for i in xrange(len(probs)): + print 'Predicted price: ${:,.2f}'.format(probs[i][0] * 1000) -- GitLab