{"id":401,"date":"2020-07-11T16:10:53","date_gmt":"2020-07-11T08:10:53","guid":{"rendered":"https:\/\/www.wangliguang.cn\/?p=401"},"modified":"2020-07-11T16:10:53","modified_gmt":"2020-07-11T08:10:53","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e5%ae%89%e8%a3%85tensorflow%e6%95%99%e7%a8%8b%ef%bc%81%e8%b6%85%e8%af%a6%e7%bb%86%ef%bc%81","status":"publish","type":"post","link":"https:\/\/wangliguang.cn\/?p=401","title":{"rendered":"\u6811\u8393\u6d3e\u5b89\u88c5TensorFlow\u6559\u7a0b\uff01\u6811\u8393\u6d3e\u5b89\u88c5TensorFlow2.0\uff01\u8d85\u8be6\u7ec6\uff01"},"content":{"rendered":"<p>\u672c\u6587\u9996\u53d1\u4e8e\u6211\u7684\u7f16\u7a0b\u4e4b\u8def\uff0c\u6587\u7ae0\u94fe\u63a5\uff1a<a href=\"https:\/\/www.wangliguang.cn\/?p=401\">https:\/\/www.wangliguang.cn\/?p=401<\/a>\uff0c\u672a\u7ecf\u5141\u8bb8\u7981\u6b62\u5546\u4e1a\u7f51\u7ad9\u8f6c\u8f7d\uff0c\u5982\u9700\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u3002\u4e2a\u4eba\u57fa\u4e8e\u6280\u672f\u5b66\u4e60\u76ee\u7684\u8f6c\u8f7d\u548c\u5206\u4eab\u672c\u6587\u65f6\u65e0\u9700\u8bb8\u53ef\uff0c\u4f46\u5fc5\u987b\u6307\u660e\u672c\u6587\u4f5c\u8005\u548c\u539f\u6587\u94fe\u63a5\u5e76\u4fdd\u7559\u672c\u6bb5\u6587\u5b57\uff0c\u5426\u5219\u7981\u6b62\u8f6c\u8f7d\u3002<\/p>\n<h2>1 \u80cc\u666f<\/h2>\n<p>\u7ed9\u6811\u8393\u6d3e\u5b89\u88c5\u4e00\u4e2aTensorFlow\u5427\uff01\u7f51\u4e0a\u5f88\u591a\u6559\u7a0b\u9648\u65e7\u4e14\u6709\u9519\u8bef\u3002\u672c\u6587\u7ecf\u8fc7\u4f5c\u8005\u5927\u91cf\u67e5\u9605\u8d44\u6599\u548cTensorFlow\u5b98\u7f51\uff0c\u5e76\u4eb2\u81ea\u6d4b\u8bd5\u5b89\u88c5\u6210\u529f\uff01<br \/>\n\u786c\u4ef6\u51c6\u5907\uff1a\u6811\u8393\u6d3e3B+<br \/>\n\u64cd\u4f5c\u7cfb\u7edf\uff1aRaspberry Pi OS 2020\u5e745\u6708\u7248<\/p>\n<h2>2 \u64cd\u4f5c\u65b9\u6cd5<\/h2>\n<p>1\u3001\u6811\u8393\u6d3e\u7cfb\u7edf\u5207\u6362\u56fd\u5185\u955c\u50cf\u3002<br \/>\n\u6811\u8393\u6d3e\u7cfb\u7edf\u5207\u6362\u56fd\u5185\u955c\u50cf\u8bf7\u53c2\u8003\u6b64\u6587\uff1a<a href=\"https:\/\/www.wangliguang.cn\/?p=394\">https:\/\/www.wangliguang.cn\/?p=394<\/a><\/p>\n<p>2\u3001\u68c0\u67e5\u73af\u5883\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u3002<\/p>\n<pre><code>python3 --version\npip3 --version\nvirtualenv --version<\/code><\/pre>\n<p>\u5982\u679c\u67d0\u4e00\u6761\u547d\u4ee4\u8fd0\u884c\u65f6\u63d0\u793a\u672a\u627e\u5230\uff0c\u5219\u672a\u5b89\u88c5\uff0c\u9700\u8981\u5728\u7b2c\u4e09\u6b65\u4e2d\u9009\u62e9\u76f8\u5e94\u547d\u4ee4\u5b89\u88c5\u3002<\/p>\n<p>3\u3001\u5b89\u88c5\u672a\u5b89\u88c5\u7684\u6a21\u5757\uff0c\u6839\u636e\u7b2c2\u6b65\uff0c\u4ece\u4e0b\u9762\u547d\u4ee4\u4e2d\u6309\u9700\u9009\u62e9\u5373\u53ef\uff0c<strong>\u5176\u4e2d\u5b89\u88c5libatlas-base-dev\u7684\u547d\u4ee4\u5fc5\u9009<\/strong>\u3002<\/p>\n<pre><code>sudo apt update  # \u6b64\u547d\u4ee4\u5fc5\u9009\nsudo apt install python3-dev python3-pip  # \u5982\u5df2\u7ecf\u5b89\u88c5\u4e86Python3\u548cpip3\u5219\u8df3\u8fc7\u6b64\u547d\u4ee4\nsudo apt install libatlas-base-dev  # \u6b64\u547d\u4ee4\u5fc5\u9009\nsudo pip3 install -U virtualenv  # \u5982\u679c\u5df2\u7ecf\u5b89\u88c5\u4e86\u865a\u62df\u73af\u5883\uff0c\u8df3\u8fc7\u6b64\u547d\u4ee4<\/code><\/pre>\n<p>4\u3001\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/p>\n<pre><code>virtualenv --system-site-packages -p python3 .\/venv<\/code><\/pre>\n<p>5\u3001\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002<\/p>\n<pre><code>source .\/venv\/bin\/activate<\/code><\/pre>\n<p>6\u3001pip\u5207\u6362\u56fd\u5185\u6e90\u3002<br \/>\n\u4e3a\u9632\u6b62\u7f51\u901f\u8fc7\u6162\uff0c\u5efa\u8baepip\u4e5f\u5207\u6362\u56fd\u5185\u6e90\u3002\u6b64\u5904\u9009\u62e9\u6e05\u534e\u6e90\u3002<\/p>\n<pre><code>pip config set global.index-url https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/code><\/pre>\n<p>7\u3001\u66f4\u65b0pip\u3002<\/p>\n<pre><code>pip install --upgrade pip<\/code><\/pre>\n<p>8\u3001\u5b89\u88c5\u4f9d\u8d56\u5305<\/p>\n<pre><code>pip install keras_applications==1.0.8 --no-deps\npip install keras_preprocessing==1.1.0 --no-deps\npip install h5py==2.9.0\npip install -U six wheel mock<\/code><\/pre>\n<p><strong>\u5728\u5b89\u88c5\u4f9d\u8d56\u5305\u65f6\uff0c\u6709\u7684\u5305\u6e05\u534e\u6e90\u6709\uff0c\u5b89\u88c5\u901f\u5ea6\u5f88\u5feb\u3002\u6709\u7684\u5305\u6e05\u534e\u6e90\u6ca1\u6709\uff0c\u4f1a\u5230\u9ed8\u8ba4\u6e90\u53bb\u4e0b\u8f7d\uff0c\u4f1a\u5f88\u6162\u751a\u81f3\u8d85\u65f6\u5931\u8d25\u3002\u5982\u9047\u8d85\u65f6\u5931\u8d25\u9700\u8981\u91cd\u8bd5\u3002<\/strong><\/p>\n<p>9\u3001\u4e0b\u8f7dTensorFlow2.0\u3002<br \/>\n\u4e0b\u8f7d\u94fe\u63a5\uff1a <a href=\"https:\/\/github.com\/lhelontra\/tensorflow-on-arm\/releases\" title=\"https:\/\/github.com\/lhelontra\/tensorflow-on-arm\/releases\">https:\/\/github.com\/lhelontra\/tensorflow-on-arm\/releases<\/a><br \/>\n\u63a8\u8350tensorflow-2.0.0-cp37-none-linux_armv7l.whl\u8fd9\u4e2a\u7248\u672c\uff0c\u56e0\u4e3a\u6211\u5b89\u88c5\u8fd9\u4e2a\u7248\u672c\u6210\u529f\u4e86\u3002<br \/>\n\u5982\u679c\u901f\u5ea6\u8fc7\u6162\uff0c\u53ef\u4ee5\u76f4\u63a5\u767e\u5ea6tensorflow-2.0.0-cp37-none-linux_armv7l.whl\uff0c\u6709\u5f88\u591a\u56fd\u5185\u8d44\u6e90\u7ad9\u6709\u8fd9\u4e2a\u3002<br \/>\n<strong>\u4e0b\u8f7d\u540e\uff0c\u901a\u8fc7Xftp\u4f20\u5230\u6811\u8393\u6d3e\u4e0a\u3002<\/strong><\/p>\n<p>10\u3001\u5b89\u88c5TensorFlow\u3002\u8fdb\u5165\u5230tensorflow-2.0.0-cp37-none-linux_armv7l.whl\u6240\u5728\u76ee\u5f55\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<pre><code>pip install tensorflow-2.0.0-cp37-none-linux_armv7l.whl<\/code><\/pre>\n<p>11\u3001\u6d4b\u8bd5\u5b89\u88c5\u7ed3\u679c\u3002<br \/>\n\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>python -c &amp;quot;import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))&amp;quot;<\/code><\/pre>\n<p>\u5982\u8f93\u51fa<code>tf.Tensor(1035.3678, shape=(), dtype=float32) <\/code>\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\uff01<\/p>\n<p>\u7528\u5b8c\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>deactivate<\/code>\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/p>\n<p>12\u3001\u5b89\u88c5\u5931\u8d25\u540e\u7684\u5904\u7406\u3002<br \/>\n\u5982\u679c\u5b89\u88c5\u5931\u8d25\uff0c\u53ef\u4ee5\u91cd\u8bd5\u3002\u6b64\u65f6\u4f7f\u7528<code>rm -r venv\/<\/code>\u5220\u9664\u5b89\u88c5\u5931\u8d25\u7684TensorFlow\u6240\u5728\u865a\u62df\u73af\u5883\uff0c\u5373\u53ef\u4ece\u7b2c4\u6b65\u5f00\u59cb\u91cd\u8bd5\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff0c\u4ece\u7b2c5\u6b65\u5f00\u59cb\uff0c\u4e00\u76f4\u5904\u4e8e\u865a\u62df\u73af\u5883\u54e6\u3002<\/strong><\/p>\n<h2>3 \u5411\u4f5c\u8005\u63d0\u95ee\u548c\u652f\u6301\u4f5c\u8005<\/h2>\n<p>\u5199\u6587\u7ae0\u4e0d\u6613\uff0c\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u6709\u5e2e\u5230\u4f60\uff0c\u5e0c\u671b\u4f60\u80fd\u7ed9\u4e88\u4e00\u5b9a\u8d5e\u8d4f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u5f53\u524d\u7f51\u7ad9\u6216App\u7684\u8d5e\u8d4f\u6e20\u9053\u652f\u6301\uff0c\u6216\u8005<a href=\"https:\/\/www.wangliguang.cn\/?page_id=25\" title=\"\u70b9\u51fb\u6b64\u5904\u652f\u6301\u4f5c\u8005\">\u70b9\u51fb\u6b64\u5904\u652f\u6301\u4f5c\u8005<\/a>\uff01<br \/>\n\u5982\u679c\u5728\u9605\u8bfb\u6b64\u6587\u7ae0\u65f6\u9047\u5230\u95ee\u9898\uff0c\u53ef\u968f\u65f6\u5411<a href=\"https:\/\/www.wangliguang.cn\/?page_id=2\" title=\"\u4f5c\u8005\u63d0\u95ee\">\u70b9\u51fb\u6b64\u5904\u5411\u4f5c\u8005\u63d0\u95ee<\/a>\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u6811\u8393\u6d3e\u5b89\u88c5\u4e00\u4e2aTensorFlow\u5427\uff01\u7f51\u4e0a\u5f88\u591a\u6559\u7a0b\u9648\u65e7\u4e14\u6709\u9519\u8bef\u3002\u672c\u6587\u7ecf\u8fc7\u4f5c\u8005\u5927\u91cf\u67e5\u9605\u8d44\u6599\u548cTensorFlow\u5b98\u7f51\uff0c\u5e76\u4eb2\u81ea\u6d4b\u8bd5\u5b89\u88c5\u6210\u529f\uff01<br \/>\n\u786c\u4ef6\u51c6\u5907\uff1a\u6811\u8393\u6d3e3B+<br \/>\n\u64cd\u4f5c\u7cfb\u7edf\uff1aRaspberry Pi OS 2020\u5e745\u6708\u7248<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,18,20],"tags":[],"class_list":["post-401","post","type-post","status-publish","format-standard","hentry","category-diy","category-18","category-20"],"_links":{"self":[{"href":"https:\/\/wangliguang.cn\/index.php?rest_route=\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wangliguang.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wangliguang.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wangliguang.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wangliguang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401"}],"version-history":[{"count":0,"href":"https:\/\/wangliguang.cn\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions"}],"wp:attachment":[{"href":"https:\/\/wangliguang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wangliguang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wangliguang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}