小猪学AI—Paddle安装和训练示例

官网:http://www.paddlepaddle.org/

Github:https://github.com/PaddlePaddle/Paddle

中文手册:http://www.paddlepaddle.org/docs/develop/documentation/fluid/zh/getstarted/index_cn.html

安装和测试过程:

#CentOS7 Root
su root

#安装依赖
yum install python python-devel -y
pip install --upgrade pip --default-timeout 600
#安装paddlepaddle 
pip uninstall paddlepaddle
pip install paddlepaddle --default-timeout 600

#创建测试脚本
mkdir /home/work/paddle && cd /home/work/paddle
vim housing.py

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())

# Infer using provided test data.
probs = paddle.infer(
    output_layer=y_predict,
    parameters=paddle.dataset.uci_housing.model(),
    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)

#测试
python housing.py

训练数据:

https://github.com/PaddlePaddle/book/raw/develop/01.fit_a_line/fit_a_line.tar

https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data

训练数据-本地cache位置:

/root/.cache/paddle/dataset/fit_a_line.tar/fit_a_line.tar

/root/.cache/paddle/dataset/uci_housing/housing.data

打印出的预测住房数据的清单:

yan 2018.4.5 15:21

欢迎关注下方“非著名资深码农“公众号进行交流~

发表评论

邮箱地址不会被公开。