

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# TensorFlow 2
<a name="tutorial-tensorflow-2"></a>

本教學課程示範如何在執行具有 Conda 的深度學習 AMI (Conda 上的 DLAMI) 的執行個體上啟用 TensorFlow 2，並執行 TensorFlow 2 程式。

發行穩定的架構 Conda 套件時，會進行測試並預先安裝在 DLAMI 上。

## 啟用 TensorFlow 2
<a name="tutorial-tensorflow-2-overview"></a>

**使用 Conda 在 DLAMI 上執行 TensorFlow**

1. 若要啟用 TensorFlow 2，請使用 Conda 開啟 DLAMI 的 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體。

1. 對於使用 CUDA 10.1 和 MKL-DNN 的 Python 3 上的 TensorFlow 2 和 Keras 2，請執行此命令：

   ```
   $ source activate tensorflow2_p310
   ```

1. 啟動 iPython 終端機：

   ```
   (tensorflow2_p310)$ ipython
   ```

1. 執行 TensorFlow 2 程式，以驗證其運作正常：

   ```
   import tensorflow as tf
   hello = tf.constant('Hello, TensorFlow!')
   tf.print(hello)
   ```

   `Hello, TensorFlow!` 應該會出現在您的畫面上。

## 其他教學
<a name="tutorial-tensorflow-2-more"></a>

如需更多教學課程和範例，請參閱 TensorFlow [Python API 的 TensorFlow ](https://www.tensorflow.org/api_docs/python/) 文件，或參閱 [TensorFlow](https://www.tensorflow.org) 網站。