TensorFlow 安裝和實踐

TensorFlow是什么?

谷歌開發(fā)的一個深度學(xué)習(xí)的框架。使用它無需過多關(guān)注內(nèi)部的實現(xiàn),就可以簡單的實現(xiàn)手寫數(shù)字識別等功能。

安裝

tensorflow 官網(wǎng)提供了很多種安裝方式,可前往了解,這里使用國內(nèi)常用的一種安裝方式,沙箱模式。
#######沙箱模式?
就是創(chuàng)建一個文件夾,里面有python運行所需的所有程序文件,理論的講就是獨立的運行環(huán)境。

pip 安裝(已經(jīng)安裝,跳過)

安裝tensorflow 和 沙箱 都需要依賴pip。

macbook:~ wany$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
...
片刻后安裝成功

安裝沙箱

macbook:~ wany$sudo pip install --upgrade virtualenv //安裝沙箱管理器
macbook:~ wany$virtualenv --system-site-packages tensorflow //創(chuàng)建沙箱
macbook:~ wany$cd tensorflow //進(jìn)入沙箱
macbook: tensorflow wany$source bin/activate //激活沙箱(activate里的代碼里好像就是改了一下路徑)
macbook: tensorflow wany$sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl //安裝tensorflow(Google官網(wǎng)下載)

退出沙箱

(tensorflow) macbook: tensorflow wany$deactivate
macbook: tensorflow wany$

開始使用
(tensorflow) macbook:tensorflow faiwong$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-07-19 22:05:52.941576: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-19 22:05:52.941605: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-19 22:05:52.941614: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-19 22:05:52.941622: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> 

關(guān)于具體函數(shù)的含義,之后更新

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 網(wǎng)址 下載與安裝 你可以使用我們提供的 Pip, Docker, Virtualenv, Anaconda 或 源...
    九七學(xué)姐閱讀 4,938評論 3 11
  • 1. 介紹 首先讓我們來看看TensorFlow! 但是在我們開始之前,我們先來看看Python API中的Ten...
    JasonJe閱讀 11,983評論 1 32
  • xx好厲害,有了自己的工作室,聽說還辦的風(fēng)聲水起,最近整個團(tuán)隊準(zhǔn)備自駕游呢。xx在報刊上發(fā)表了自己的文章,還有著作...
    花花果閱讀 113評論 0 0
  • 我很想和你有很多話說,但是真的不知道說什么,我很想努力成為一個好的女朋友,我靜靜的等著你的消息,可能你真的失望了吧...
    陌雨沐閱讀 325評論 0 0
  • 原來海綿寶寶是個講愛情的動畫,海洋動物和陸地動物,水和空氣,死宅和現(xiàn)充…… 就算曬成干海綿也要豎起小拇指,【我不需...
    heim_dn閱讀 884評論 0 0

友情鏈接更多精彩內(nèi)容