TensorFlow 2 教學:TensorFlow2 總覽、介紹

tensorflow

TensorFlow2 教學系列 : 這篇文章會整理 TensorFlow2的特性、學習資源,並且持續更新……

前言

  • 這篇文章將跟大家介紹 TensorFlow 2 的特點,所有想入門 TensorFlow 2 的人都建議閱覽過這篇文章,建立一個Big Picture。
  • TensorFlow 2 在今年推出,目前已經推出到 RC 版本(Release Candidate)。TensorFlow 2 跟 TensorFlow 1最大的差別是變得更容易使用、寫起來更 “Pythonic”。

TensorFlow2 特色

1. API clean up:

TensorFlow 2 整理了之前為人詬病的 API,以前同一種功能、API可能有很多種 call 法,這次 TensorFlow 將 API 整頓了一番,並刪除了很多不必要的 APIs。

2. Eager Execution

以前在 TensorFlow1 需要將 tensor 餵給 session.run() 來 compile graph,在 TensorFlow 2 可以動態建立 graph,”executes eagerly” : 在執行時可以即時把值 return 回來不再需要 session.run(),這樣更容易 debug、寫起來更直覺也更像 Python。

3. SavedModel

SavedModel 包含了整個 TensorFlow Model,完全獨立於程式碼。在 TensorFlow 2,model 的傳送、分享、deployment ( TFLiteTensorFlow.js …)變得更直覺 。日後也會寫文章介紹在不同平台上的TensorFlow。 在 Raspberry Pi 或 Browser !!

TensorFlow_SavedModel

學習資源

要學 TensorFlow 2 有幾點需要注意,以免踩到雷去學到舊的 TensorFlow 1,以下是 TensorFlow 1 的關鍵字,看到這些代表這還是 TensorFlow 1,可以避開:

  • tf.enable_eager_execution()
  • session.run
  • tf.placeholder
  • feed_dict

1. TensorFlow 官方網站
2. TensorFlow Github 開源網址
3. TensorFlow in Practice, Coursera課程 by deeplearning.ai
4. Hands-on Machine Learning with Scikit-Learn, Keras and TensorFlow 2.0*
5. Deep Learning with Python by François Chollet*

4*. Hands on Machine Learning 那本目前第二版還沒出,第一版是 tensorflow1 可以跳過,不過 tensorflow2的版本在 github 上面已經有。
5*. Deep Learning with Python 這本裡面的觀念都很實用,裡面是使用 Keras,因此在TensorFlow 2只需要改變 import 的部分就可以。這本寫得非常好,作者 Francois Chollet 是 Keras 爸爸之一,大推!!!!!

留言討論區