TensorFlow是什么岔激?
谷歌開發(fā)的一個深度學習的框架。使用它無需過多關(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 //進入沙箱
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ù)的含義席里,之后更新