<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Python 深度學習庫 TensorFlow 簡介 > 原文: [https://machinelearningmastery.com/introduction-python-deep-learning-library-tensorflow/](https://machinelearningmastery.com/introduction-python-deep-learning-library-tensorflow/) TensorFlow 是一個用于 Google 創建和發布的快速數值計算的 Python 庫。 它是一個基礎庫,可用于直接創建深度學習模型,或使用包裝庫來簡化在 TensorFlow 之上構建的過程。 在這篇文章中,您將學習用于深度學習的 TensorFlow 庫。 在我的[新書](https://machinelearningmastery.com/deep-learning-with-python/)中,通過 18 個漸進式的教程和 9 個項目,探索如何用幾行代碼為一系列預測建模問題開發深度學習模型。 讓我們開始吧。 ![Introduction to the Python Deep Learning Library TensorFlow](https://img.kancloud.cn/36/5a/365ad560491148c9082b94e34d4f1b03_640x244.png) Python 深度學習庫簡介 TensorFlow 攝影: [Nicolas Raymond](https://www.flickr.com/photos/82955120@N05/15932303392/) ,保留權利。 ## 什么是 TensorFlow? TensorFlow 是一個用于快速數值計算的開源庫。 它由 Google 創建并維護,并在 Apache 2.0 開源許可下發布。雖然可以訪問底層的 C ++ API,但 API 名義上是用于 Python 編程語言的。 與 Theano 等深度學習中使用的其他庫不同,TensorFlow 設計用于研究和開發以及企業生產環境系統,尤其是 [谷歌搜索RankBrain項目 ](https://en.wikipedia.org/wiki/RankBrain) 和有趣的[DeepDream 項目](https://en.wikipedia.org/wiki/DeepDream) ]。 它可以在單 CPU 系統,GPU 以及移動設備和數百臺機器的大規模分布式系統上運行。 ## 如何安裝 TensorFlow 如果您已經擁有 Python SciPy 環境,那么 TensorFlow 的安裝非常簡單。 TensorFlow 適用于 Python 2.7 和 Python 3.3+。您可以按照 TensorFlow 網站上的[下載和設置說明](https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html)進行操作。通過 PyPI 進行安裝可能是最簡單的,并且下載和設置網頁上有用于 Linux 或 Mac OS X 平臺的 pip 命令的特定說明。 如果您愿意,還可以使用 [虛擬機環境](http://docs.python-guide.org/en/latest/dev/virtualenvs/) 和[docker鏡像](https://www.docker.com/)。 只有Linux系統支持GPU,并且還需要安裝Cuda工具包。 ## 使用TensorFlow創建第一個示例 根據有向圖的結構中的數據流和操作來描述計算。 * **節點**:節點執行計算并具有零個或多個輸入和輸出。在節點之間移動的數據稱為張量,它是實數值的多維數組。 * **邊界** :該圖定義了數據流,分支,循環和狀態更新。特殊邊緣可用于同步圖形中的行為,例如等待完成多個輸入的計算。 * **操作**:一個操作是一個命名的抽象計算,它可以獲取輸入屬性并產生輸出屬性。例如,您可以定義加法或乘法操作。 ### 使用 TensorFlow 計算 第一個示例是 [TensorFlow](https://github.com/tensorflow/tensorflow)上的示例的修改版本。它向你展示了如何創建一個session,在這個session中定義常量并使用常量進行計算。 ```py import tensorflow as tf sess = tf.Session() a = tf.constant(10) b = tf.constant(32) print(sess.run(a+b)) ``` 運行此示例顯示: ```py 42 ``` ### 使用 TensorFlow 進行線性回歸 第二個示例來自 [TensorFlow 教程](https://www.tensorflow.org/versions/r0.8/get_started/index.html)的介紹。 此示例顯示了如何定義變量(例如 W 和 b)以及變量(y)接收結果輸出。 我們對 TensorFlow 有一定的了解,它將計算的定義和聲明與session中的執行和運行調用分開。 ```py import tensorflow as tf import numpy as np # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3 x_data = np.random.rand(100).astype(np.float32) y_data = x_data * 0.1 + 0.3 # Try to find values for W and b that compute y_data = W * x_data + b # (We know that W should be 0.1 and b 0.3, but Tensorflow will # figure that out for us.) W = tf.Variable(tf.random_uniform([1], -1.0, 1.0)) b = tf.Variable(tf.zeros([1])) y = W * x_data + b # Minimize the mean squared errors. loss = tf.reduce_mean(tf.square(y - y_data)) optimizer = tf.train.GradientDescentOptimizer(0.5) train = optimizer.minimize(loss) # Before starting, initialize the variables. We will 'run' this first. init = tf.initialize_all_variables() # Launch the graph. sess = tf.Session() sess.run(init) # Fit the line. for step in xrange(201): sess.run(train) if step % 20 == 0: print(step, sess.run(W), sess.run(b)) # Learns best fit is W: [0.1], b: [0.3] ``` 運行此示例將輸出以下內容: ```py (0, array([ 0.2629351], dtype=float32), array([ 0.28697217], dtype=float32)) (20, array([ 0.13929555], dtype=float32), array([ 0.27992988], dtype=float32)) (40, array([ 0.11148042], dtype=float32), array([ 0.2941364], dtype=float32)) (60, array([ 0.10335406], dtype=float32), array([ 0.29828694], dtype=float32)) (80, array([ 0.1009799], dtype=float32), array([ 0.29949954], dtype=float32)) (100, array([ 0.10028629], dtype=float32), array([ 0.2998538], dtype=float32)) (120, array([ 0.10008363], dtype=float32), array([ 0.29995731], dtype=float32)) (140, array([ 0.10002445], dtype=float32), array([ 0.29998752], dtype=float32)) (160, array([ 0.10000713], dtype=float32), array([ 0.29999638], dtype=float32)) (180, array([ 0.10000207], dtype=float32), array([ 0.29999897], dtype=float32)) (200, array([ 0.1000006], dtype=float32), array([ 0.29999971], dtype=float32)) ``` 您可以在[基本使用指南](https://www.tensorflow.org/versions/r0.8/get_started/basic_usage.html)中了解有關 TensorFlow 的更多信息。 ## 更多深度學習模型 您的 TensorFlow 安裝包中附帶了許多深度學習模型,您可以直接使用它們。 首先,您需要找到 TensorFlow 的安裝位置。例如,您可以使用以下 Python 腳本: ```py python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))' ``` 例如,它可能是這樣的: ```py /usr/lib/python2.7/site-packages/tensorflow ``` 切換到此目錄并記下 models 子目錄。包括許多深度學習模型,包含類似教程的注釋,例如: * 多線程 word2vec 小批量skip-gram模型。 * 多線程 word2vec 全量 skip-gram 模型。 * CNN CIFAR-10 網絡。 * 簡單,端到端,類似 LeNet-5 的卷積 MNIST 模型示例。 * Seq2seq模型。 還要檢查 examples 目錄,因為它包含使用 MNIST 數據集的示例。 在 TensorFlow 主網站上還有一個很全好的[教程列表](https://www.tensorflow.org/versions/r0.8/tutorials/index.html)。它們展示了如何使用不同的網絡類型,不同的數據集以及如何以各種不同的方式使用框架。 最后,有 [TensorFlow實驗室](http://playground.tensorflow.org/),您可以在 Web 瀏覽器中試驗小型網絡。 ## TensorFlow 資源 * [TensorFlow 官方主頁](https://www.tensorflow.org/) * [GitHub 上的 TensforFlow 項目](https://github.com/tensorflow/tensorflow) * [TensorFlow 教程](https://www.tensorflow.org/versions/r0.7/tutorials/index.html) ### 更多資源 * [關于 Udacity 的 TensorFlow 課程](https://www.udacity.com/course/deep-learning--ud730) * [TensorFlow:異構分布式系統上的大規模機器學習](http://download.tensorflow.org/paper/whitepaper2015.pdf)(2015) ## 摘要 在這篇文章中,您發現了用于深度學習的 TensorFlow Python 庫。 您了解到它是一個快速數值計算庫,專門為大型深度學習模型的開發和評估所需的操作類型而設計。 您對 TensorFlow 或者這篇文章有任何疑問嗎?在評論中提出您的問題,我會盡力回答。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看