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)
出现:
otool -L /anaconda2/lib/python2.7/site-packages/py_paddle/_swig_paddle.so
得到:
/anaconda2/lib/python2.7/site-packages/py_paddle/_swig_paddle.so
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1445.12.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 58286.20.16)
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
发现并没有/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python 这个路径。
install_name_tool -change /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Python /anaconda/lib/libpython2.7.dylib /anaconda/lib/python2.7/site-packages/py_paddle/_swig_paddle.so
此时运行paddlepaddle的tutorial,成功。
I0326 20:41:27.464560 3940180928 Util.cpp:166] commandline: –use_gpu=False –trainer_count=1
Cache file /Users/suiyang/.cache/paddle/dataset/uci_housing/housing.data not found, downloading https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data[==== ]
[======== ]
[============ ]
[================ ]
[==================== ]
[========================= ]
[============================= ]
[================================= ]
[===================================== ]
[========================================= ]
[============================================= ]
[==================================================]Predicted price: 12,316.63Predictedprice: 12 , 316.63 P r e d i c t e d p r i c e : 13,830.34
Predicted price: 11,499.34Predictedprice: 11 , 499.34 P r e d i c t e d p r i c e : 17,395.05
Predicted price: 13,317.67Predictedprice: 13 , 317.67 P r e d i c t e d p r i c e : 16,834.08
Predicted price: 16,632.04Predictedprice: 16 , 632.04 P r e d i c t e d p r i c e : 15,384.20
Predicted price: 7,697.38Predictedprice: 7 , 697.38 P r e d i c t e d p r i c e : 13,657.83
Predicted price: 6,329.62Predictedprice: 6 , 329.62 P r e d i c t e d p r i c e : 12,153.18
Predicted price: 13,890.60Predictedprice: 13 , 890.60 P r e d i c t e d p r i c e : 11,367.41
Predicted price: 13,269.13Predictedprice: 13 , 269.13 P r e d i c t e d p r i c e : 14,979.35
Predicted price: 17,539.03Predictedprice: 17 , 539.03 P r e d i c t e d p r i c e : 16,686.41
Predicted price: 16,810.74Predictedprice: 16 , 810.74 P r e d i c t e d p r i c e : 13,620.53
Predicted price: 14,720.09Predictedprice: 14 , 720.09 P r e d i c t e d p r i c e : 12,533.42
Predicted price: 15,835.49Predictedprice: 15 , 835.49 P r e d i c t e d p r i c e : 16,064.76
Predicted price: 14,566.97Predictedprice: 14 , 566.97 P r e d i c t e d p r i c e : 13,783.11
Predicted price: 16,211.73Predictedprice: 16 , 211.73 P r e d i c t e d p r i c e : 16,362.79
Predicted price: 18,183.92Predictedprice: 18 , 183.92 P r e d i c t e d p r i c e : 16,298.03
Predicted price: 16,084.58Predictedprice: 16 , 084.58 P r e d i c t e d p r i c e : 14,406.07
Predicted price: 15,309.62Predictedprice: 15 , 309.62 P r e d i c t e d p r i c e : 12,104.60
Predicted price: 9,865.44Predictedprice: 9 , 865.44 P r e d i c t e d p r i c e : 14,116.36
Predicted price: 14,552.37Predictedprice: 14 , 552.37 P r e d i c t e d p r i c e : 16,381.32
Predicted price: 16,992.90Predictedprice: 16 , 992.90 P r e d i c t e d p r i c e : 16,722.93
Predicted price: 13,468.48Predictedprice: 13 , 468.48 P r e d i c t e d p r i c e : 13,622.97
Predicted price: 16,512.31Predictedprice: 16 , 512.31 P r e d i c t e d p r i c e : 17,004.60
Predicted price: 16,492.97Predictedprice: 16 , 492.97 P r e d i c t e d p r i c e : 16,179.70
Predicted price: 15,989.17Predictedprice: 15 , 989.17 P r e d i c t e d p r i c e : 17,289.17
Predicted price: 16,975.07Predictedprice: 16 , 975.07 P r e d i c t e d p r i c e : 18,950.22
Predicted price: 15,513.54Predictedprice: 15 , 513.54 P r e d i c t e d p r i c e : 15,652.08
Predicted price: 14,162.51Predictedprice: 14 , 162.51 P r e d i c t e d p r i c e : 14,665.31
Predicted price: 16,724.47Predictedprice: 16 , 724.47 P r e d i c t e d p r i c e : 17,369.51
Predicted price: 17,330.55Predictedprice: 17 , 330.55 P r e d i c t e d p r i c e : 17,923.71
Predicted price: 18,018.71Predictedprice: 18 , 018.71 P r e d i c t e d p r i c e : 19,392.96
Predicted price: 18,379.00Predictedprice: 18 , 379.00 P r e d i c t e d p r i c e : 17,187.61
Predicted price: 14,920.71Predictedprice: 14 , 920.71 P r e d i c t e d p r i c e : 15,435.08
Predicted price: 16,458.07Predictedprice: 16 , 458.07 P r e d i c t e d p r i c e : 17,390.93
Predicted price: 17,520.05Predictedprice: 17 , 520.05 P r e d i c t e d p r i c e : 18,763.72
Predicted price: 18,698.70Predictedprice: 18 , 698.70 P r e d i c t e d p r i c e : 20,425.67
Predicted price: 15,431.77Predictedprice: 15 , 431.77 P r e d i c t e d p r i c e : 14,803.56
Predicted price: 17,336.69Predictedprice: 17 , 336.69 P r e d i c t e d p r i c e : 13,052.34
Predicted price: 16,874.23Predictedprice: 16 , 874.23 P r e d i c t e d p r i c e : 18,547.62
Predicted price: 19,574.30Predictedprice: 19 , 574.30 P r e d i c t e d p r i c e : 21,303.89
Predicted price: 22,053.60Predictedprice: 22 , 053.60 P r e d i c t e d p r i c e : 18,862.40
Predicted price: 17,969.15Predictedprice: 17 , 969.15 P r e d i c t e d p r i c e : 19,496.96
Predicted price: 17,676.56Predictedprice: 17 , 676.56 P r e d i c t e d p r i c e : 18,699.87
Predicted price: 14,520.48Predictedprice: 14 , 520.48 P r e d i c t e d p r i c e : 12,410.05
Predicted price: 9,987.12Predictedprice: 9 , 987.12 P r e d i c t e d p r i c e : 15,381.11
Predicted price: 16,906.17Predictedprice: 16 , 906.17 P r e d i c t e d p r i c e : 21,538.57
Predicted price: 21,566.74Predictedprice: 21 , 566.74 P r e d i c t e d p r i c e : 19,905.33
Predicted price: 17,938.98Predictedprice: 17 , 938.98 P r e d i c t e d p r i c e : 20,776.08
Predicted price: 21,715.28Predictedprice: 21 , 715.28 P r e d i c t e d p r i c e : 20,169.60
Predicted price: 21,148.05Predictedprice: 21 , 148.05 P r e d i c t e d p r i c e : 22,589.09
Predicted price: 21,913.31Predictedprice: 21 , 913.31 P r e d i c t e d p r i c e : 24,388.41
Predicted price: 23,748.72Predictedprice: 23 , 748.72 P r e d i c t e d p r i c e : 22,013.94
[Finished in 8.5s]