From d4b400241bc6e8cab5fceeaaf6c75d32edf4cbf4 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Wed, 17 May 2017 19:27:48 +0800 Subject: [PATCH] add inference for book chapter 1 --- 01.fit_a_line/README.en.md | 27 +++++++++++++++++++++++++++ 01.fit_a_line/README.md | 27 +++++++++++++++++++++++++++ 01.fit_a_line/index.en.html | 27 +++++++++++++++++++++++++++ 01.fit_a_line/index.html | 27 +++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/01.fit_a_line/README.en.md b/01.fit_a_line/README.en.md index 31341db..934b28e 100644 --- a/01.fit_a_line/README.en.md +++ b/01.fit_a_line/README.en.md @@ -222,6 +222,33 @@ trainer.train( ![png](./image/train_and_test.png) +### Apply model + +#### 1. generate testing data + +```python +test_data_creator = paddle.dataset.uci_housing.test() +test_data = [] + +for item in test_data_creator(): + test_data.append((item[0], )) + if len(test_data) == 5: + break + +for data in test_data: + print data +``` + +#### 2. inference + +```python +probs = paddle.infer( + output_layer=y_predict, parameters=parameters, input=test_data) + +for data in probs: + print data +``` + ## Summary This chapter introduces *Linear Regression* and how to train and test this model with PaddlePaddle, using the UCI Housing Data Set. Because a large number of more complex models and techniques are derived from linear regression, it is important to understand its underlying theory and limitation. diff --git a/01.fit_a_line/README.md b/01.fit_a_line/README.md index 4595007..7fbd4f3 100644 --- a/01.fit_a_line/README.md +++ b/01.fit_a_line/README.md @@ -217,6 +217,33 @@ trainer.train( ![png](./image/train_and_test.png) +### 应用模型 + +#### 1. 生成测试数据 + +```python +test_data_creator = paddle.dataset.uci_housing.test() +test_data = [] + +for item in test_data_creator(): + test_data.append((item[0], )) + if len(test_data) == 5: + break + +for data in test_data: + print data +``` + +#### 2. 推测 inference + +```python +probs = paddle.infer( + output_layer=y_predict, parameters=parameters, input=test_data) + +for data in probs: + print data +``` + ## 总结 在这章里,我们借助波士顿房价这一数据集,介绍了线性回归模型的基本概念,以及如何使用PaddlePaddle实现训练和测试的过程。很多的模型和技巧都是从简单的线性回归模型演化而来,因此弄清楚线性模型的原理和局限非常重要。 diff --git a/01.fit_a_line/index.en.html b/01.fit_a_line/index.en.html index fdb8c89..59590c5 100644 --- a/01.fit_a_line/index.en.html +++ b/01.fit_a_line/index.en.html @@ -264,6 +264,33 @@ trainer.train( ![png](./image/train_and_test.png) +### Apply model + +#### 1. generate testing data + +```python +test_data_creator = paddle.dataset.uci_housing.test() +test_data = [] + +for item in test_data_creator(): + test_data.append((item[0], )) + if len(test_data) == 5: + break + +for data in test_data: + print data +``` + +#### 2. inference + +```python +probs = paddle.infer( + output_layer=y_predict, parameters=parameters, input=test_data) + +for data in probs: + print data +``` + ## Summary This chapter introduces *Linear Regression* and how to train and test this model with PaddlePaddle, using the UCI Housing Data Set. Because a large number of more complex models and techniques are derived from linear regression, it is important to understand its underlying theory and limitation. diff --git a/01.fit_a_line/index.html b/01.fit_a_line/index.html index cac6ce7..1f6f23e 100644 --- a/01.fit_a_line/index.html +++ b/01.fit_a_line/index.html @@ -259,6 +259,33 @@ trainer.train( ![png](./image/train_and_test.png) +### 应用模型 + +#### 1. 生成测试数据 + +```python +test_data_creator = paddle.dataset.uci_housing.test() +test_data = [] + +for item in test_data_creator(): + test_data.append((item[0], )) + if len(test_data) == 5: + break + +for data in test_data: + print data +``` + +#### 2. 推测 inference + +```python +probs = paddle.infer( + output_layer=y_predict, parameters=parameters, input=test_data) + +for data in probs: + print data +``` + ## 总结 在这章里,我们借助波士顿房价这一数据集,介绍了线性回归模型的基本概念,以及如何使用PaddlePaddle实现训练和测试的过程。很多的模型和技巧都是从简单的线性回归模型演化而来,因此弄清楚线性模型的原理和局限非常重要。 -- GitLab