前面寫了 TensorFlow 在Windows上的安裝教程,當時版本還是 0.12 。
NOW
首屆 TensorFlow 開發者大會(TensorFlow Dev Summit)已于美國時間昨日召開,YouTube 還進行了直播。更重要的是,TensorFlow 1.0 版本發布。Google Research Blog 也于昨天在 博客 中公布了這一消息。

這一版本的改動還是比較大的,很多舊的 API 都已經不再使用。在 博客 中可以看到 1.0 版本更快、更靈活、更穩定(PRoduction-ready) 。TensorFlow 1.0 版本保證 Python API 的穩定性,即使以后添加新的特性也不用擔心會破壞現有代碼。
博客中提到的其他新版本兩點(為避免翻譯造成的偏差,我就直接引用原文了):
Python APIs have been changed to resemble NumPy more closely. For this and other backwards-incompatible changes made to support API stability going forward, please use our handy migration guide and conversion script.Experimental APIs for java and GoHigher-level API modules tf.layers, tf.metrics, and tf.losses - brought over from tf.contrib.learn after incorporating skflow and TF SlimExperimental release of XLA, a domain-specific compiler for TensorFlow graphs, that targets CPUs and GPUs. XLA is rapidly evolving - expect to see more progress in upcoming releases.Introduction of the TensorFlow Debugger (tfdbg), a command-line interface and API for debugging live TensorFlow programs.New Android demos for object detection and localization, and camera-based image stylization.Installation improvements: Python 3 docker images have been added, and TensorFlow’s pip packages are now PyPI compliant. This means TensorFlow can now be installed with a simple invocation ofpip install tensorflow.升級很簡單(在這里感謝一下為簡化 TensorFlow 安裝過程的工程師們),就是一行語句,這也是安裝命令:
對于 GPU 版本:
pip3 install --upgrade tensorflow-gpu對于 CPU 版本:
pip3 install --upgrade tensorflow
右鍵在新標簽頁打開圖片可查看大圖
輸入完回車就開始升級過程,會下載并卸載重裝一些必要的包,時間長短視網速而定。
有兩種方法更新你的代碼,一種就是我上面提到的用腳本自動升級,另一種就是手動更改,具體可以參考 這里 。
由于版本改動較大,TensorFlow 甚至出了一個 tf_upgrade.py 腳本來幫助你更新代碼,從 這里 獲取這份代碼,或者點擊 這里 直接下載。
對于更新單個文件,可以使用下面的命令:
python tf_upgrade.py --infile InputFile --outfile OutputFile其中 InputFile 和 OutputFile 分別為你的舊代碼和新代碼,根據你的文件名做相應的替換。例如我的舊代碼是 test.py,將要生成的新代碼是 test_1.0.py,則:
同時,tf_upgrade.py 會生成一個名為 report.txt 的文件,該文件記錄了對舊文件做的所有改動,同時也給出了可能需要你手動更改的建議。
對于文件夾(目錄),和單個文件類似,使用
python tf_upgrade.py --intree InputDir --outtree OutputDir例如,我的 programs 位于 /home/user/cool 目錄,新的生成的文件我想放到 /home/user/cool_1.0 里,則
除了使用腳本自動更新外,還可以使用手動替換的方式。需要替換的東西有很多,我就不一一列舉了,大家可以參考 官網 。
新聞熱點
疑難解答