1. TensorFlow是什麼
TensorFlow是Google的開源軟件庫,有以下特點:
- 採取數據流圖,用於數值計算
- 支持多種平臺–FPU, CPU, 移動設備
- 最初用於深度學習,變得越來越通用
TensorFlow的特性:
- 高度的靈活性,體現在數據流圖上
- 真正的可移植性,可以在海量的設備上進行移植
- 產品和科研結合
- 自動求微分
- 多語言支持,支持python,Java,C++, R等
- 性能最優化
2. TensorFlow1.0與2.0架構
TensorFlow1.0的主要特性
- 對XLA支持,XLA爲Accelerate Linear Algebra, 其對TensorFlow的訓練速度提升了58倍。XLA具有很強的移植性,可以在移動設備中運行
- 引入更高級別的API—tf.layers/ tf.metrics /tf.losses/ tf.keras
- TensorFlow調試器
- 支持docker鏡像,引入TensorFlow serving服務
TensorFlow1.0的架構圖:
TensorFlow 2.0的主要特性
- 使用tf.keras和eager mode進行更加簡單的模型構建
- 魯棒的跨平臺模型部署
- 強大的研究實驗
- 清楚不推薦使用的API和減少重複來簡化API
TensorFlow 2.0的架構圖:
TensorFlow 2.0相對於TensorFlow 1.0簡化了模型開發流程:
- 使用tf,data加載數據
- 使用tf.keras構建模型,也可以使用premade estimator來驗證模型
- 使用TensorFlow hub進行遷移學習
- 使用eager mode進行運行和調試
- 使用分發策略來進行分佈式訓練
- 導出到savedmodel
- 使用TensorFlow Serve, TensorFlow Lite, TensorFlow.js部署模型
3. TensorFlow環境配置
TensorFlow的配置比較簡單,以Windows的安裝爲例:
- 首先要安裝Anaconda
- 打開anaconda prompt,並安裝TensorFlow 2:
TensorFlow2.0 CPU版本的安裝指令
conda install tensorflow=2.0.0
TensorFlow2.0 GPU版本的安裝指令
conda install tensorflow-gpu=2.0.0
- 在prompt環境中進行測試:
- 在jupyter notebook中測試: