diff --git a/01.fit_a_line/README.en.md b/01.fit_a_line/README.en.md index 31341db5e1b725ba6c646597537ef54f7bb14f9d..934b28efc1bca4ec4bdb9564fbf20feba168ff8a 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 45950078e1c09d77d9e52c9b9160e3c3458557fc..7fbd4f32ed2b7070c64827e7ff35228f6c71828c 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 fdb8c89cfad99aefea1727c89f414fc2b3ee4beb..59590c500ae744c34f3f5e08ad2ab8771c7a504f 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 cac6ce753a502d47aec931845eb014df4876d521..1f6f23efc968e8d3e2472e0aea68f2be73510772 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实现训练和测试的过程。很多的模型和技巧都是从简单的线性回归模型演化而来,因此弄清楚线性模型的原理和局限非常重要。