<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Python 深度學習庫 Keras 簡介 > 原文: [https://machinelearningmastery.com/introduction-python-deep-learning-library-keras/](https://machinelearningmastery.com/introduction-python-deep-learning-library-keras/) Python 中兩個為深度學習研究和開發提供基礎的頂級數字平臺是 Theano 和 TensorFlow。 兩者都是非常強大的庫,但兩者都難以直接用于創建深度學習模型。 在這篇文章中,您將發現 Keras Python 庫,它提供了一種在 Theano 或 TensorFlow 上創建一系列深度學習模型的簡便的方法。 讓我們開始吧。 **2016 年 10 月更新**:更新了 Keras 1.1.0,Theano 0.8.2 和 TensorFlow 0.10.0 的示例。 ![Introduction to the Python Deep Learning Library Keras](https://img.kancloud.cn/13/a3/13a355f6a3dba95c6593ef5bd1e7c17a_640x480.png) Python 深度學習庫 Keras 簡介 照片由 [Dennis Jarvis](https://www.flickr.com/photos/archer10/2216602404/) 拍攝,保留一些權利。 ## 什么是 Keras? Keras 是一個用于深度學習的極簡主義 Python 庫,可以在 Theano 或 TensorFlow 之上運行。 它的開發旨在使深度學習模型的研究和開發盡可能快速簡便地實施。 它運行在 Python 2.7 或 3.5 上,并且可以在給定底層框架的情況下在 GPU 和 CPU 上無縫執行。它是在許可的 MIT 許可下發布的。 Keras 由[Fran?oisChollet](https://www.linkedin.com/in/fchollet)開發和維護,他是一位 Google 工程師,使用四個指導原則: * **模塊性**:模型可以理解為單獨的序列或圖形。深度學習模型的所有關注點都是可以以任意方式組合的離散組件。 * **極簡主義**:該庫提供了足夠的結果,沒有多余的裝飾和最大化的可讀性。 * **可擴展性**:新組件有意在框架內輕松添加和使用,供研究人員試用和探索新想法。 * **Python** :沒有自定義文件格式的單獨模型文件。一切都是原生 Python。 ## 如何安裝 Keras 如果您已經擁有可用的 Python 和 SciPy 環境,那么 Keras 的安裝將相對簡單。 您還必須在系統上安裝 Theano 或 TensorFlow。 您可以在此處查看兩個平臺的安裝說明: * [Theano 的安裝說明](http://deeplearning.net/software/theano/install.html#install) * [TensorFlow](https://github.com/tensorflow/tensorflow#download-and-setup) 的安裝說明 使用 [PyPI](https://pypi.python.org/pypi) 可以輕松安裝 Keras,如下所示: ```py sudo pip install keras ``` 在撰寫本文時,Keras 的最新版本是 1.1.0 版。您可以使用以下代碼段在命令行上檢查您的 Keras 版本: 您可以使用以下代碼段在命令行上檢查您的 Keras 版本: ```py python -c "import keras; print keras.__version__" ``` 運行上面的腳本你會看到: ```py 1.1.0 ``` 您可以使用相同的方法升級 Keras : ```py sudo pip install --upgrade keras ``` ## 針對 Keras 的 Theano 和 TensorFlow 后端 假設您同時安裝了 Theano 和 TensorFlow,則可以配置 Keras 使用的[后端](http://keras.io/backend/)。 最簡單的方法是在主目錄中添加或編輯 Keras 配置文件: ```py ~/.keras/keras.json ``` 其格式如下: ```py { "image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" } ``` 在此配置文件中,您可以將“_ 后端 _”屬性從“ _tensorflow_ ”(默認值)更改為“ _theano_ ”。然后 Keras 將在下次運行時使用該配置。 您可以在命令行上使用以下代碼段確認 Keras 使用的后端: ```py python -c "from keras import backend; print backend._BACKEND" ``` 使用默認配置運行此選項,您將看到: ```py Using TensorFlow backend. tensorflow ``` 您還可以在命令行上通過指定 KERAS_BACKEND 環境變量來指定 Keras 使用的后端,如下所示: ```py KERAS_BACKEND=theano python -c "from keras import backend; print(backend._BACKEND)" ``` 運行此示例打印: ```py Using Theano backend. theano ``` ## 使用 Keras 構建深度學習模型 Keras 的核心是模型(`model`)的概念。 主要類型的模型稱為序列(`Sequential`)模型,它由多個網絡層(`layer`)線性堆疊。 您可以按照希望執行計算的順序來創建序列并向其添加層。 一旦定義完成,您就可以配置模型,該模型將利用底層基礎框架來優化計算。在此,您可以指定損失函數和所要使用的優化器。 模型配置完成后,必須使用適合數據來訓練模型。可以一次完成一批數據,也可以通過啟動整個模型訓練方案來完成。這是所有計算發生的地方。 完成訓練后,您可以使用模型對新數據進行預測。 我們可以總結一下 Keras 深度學習模型的構建過程如下: 1. **定義模型**。創建序列并添加層。 2. **配置模型**。指定損失函數和優化器。 3. **訓練模型**。使用數據訓練模型。 4. **模型預測**。使用該模型生成對新數據的預測。 ## Keras 資源 下面的列表提供了一些其他資源,您可以通過它們來了解有關 Keras 的更多信息。 * [Keras 官方主頁](http://keras.io/)(文檔) * [GitHub 上的 Keras 項目](https://github.com/fchollet/keras) * [Keras 用戶組](https://groups.google.com/forum/#!forum/keras-users) 您是否正在尋找一個良好的深度學習教程來開啟學習之旅,請看看: * [用 Keras 逐步開發 Python 中的第一個神經網絡](http://machinelearningmastery.com/tutorial-first-neural-network-python-keras/) ## 摘要 在這篇文章中,您了解了用于深度學習研究和開發的 Keras Python 庫。 知曉 Keras 專為極簡主義和模塊化而設計,允許您快速定義深度學習模型并以 Theano 或 TensorFlow 作為后端運行它們。 你對 Keras 或這篇文章有任何疑問嗎?請在評論中提出您的問題,我會盡力回答。
                  <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>

                              哎呀哎呀视频在线观看