資源 | 數十種TensorFlow實現案例彙集:程式碼+筆記

github_zwl發表於2017-05-11

選自 Github

機器之心編譯

這是使用 TensorFlow 實現流行的機器學習演算法的教程彙集。本彙集的目標是讓讀者可以輕鬆通過案例深入 TensorFlow。

這些案例適合那些想要清晰簡明的 TensorFlow 實現案例的初學者。本教程還包含了筆記和帶有註解的程式碼。

  • 專案地址:https://github.com/aymericdamien/TensorFlow-Examples

教程索引

0 - 先決條件

機器學習入門:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/ml_introduction.ipynb

  • MNIST 資料集入門

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/mnist_dataset_intro.ipynb

1 - 入門

Hello World:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/1_Introduction/helloworld.ipynb

  • 程式碼https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/helloworld.py

基本操作:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/1_Introduction/basic_operations.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/1_Introduction/basic_operations.py

2 - 基本模型

最近鄰:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/nearest_neighbor.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/nearest_neighbor.py

線性迴歸:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/linear_regression.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/linear_regression.py

Logistic 迴歸:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/logistic_regression.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/2_BasicModels/logistic_regression.py

3 - 神經網路

多層感知器:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/multilayer_perceptron.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/multilayer_perceptron.py

卷積神經網路:

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/convolutional_network.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/convolutional_network.py

迴圈神經網路(LSTM):

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/recurrent_network.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/recurrent_network.py

雙向迴圈神經網路(LSTM):

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/bidirectional_rnn.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/bidirectional_rnn.py

動態迴圈神經網路(LSTM)

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/dynamic_rnn.py

自編碼器

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/3_NeuralNetworks/autoencoder.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/3_NeuralNetworks/autoencoder.py

4 - 實用技術

儲存和恢復模型

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/save_restore_model.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/save_restore_model.py

圖和損失視覺化

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_basic.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_basic.py

Tensorboard——高階視覺化

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/tensorboard_advanced.py

5 - 多 GPU

多 GPU 上的基本操作

  • 筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/5_MultiGPU/multigpu_basics.ipynb

  • 程式碼:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/5_MultiGPU/multigpu_basics.py

資料集

一些案例需要 MNIST 資料集進行訓練和測試。不要擔心,執行這些案例時,該資料集會被自動下載下來(使用 input_data.py)。MNIST 是一個手寫數字的資料庫,檢視這個筆記了解關於該資料集的描述:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/mnist_dataset_intro.ipynb

  • 官方網站:http://yann.lecun.com/exdb/mnist/

更多案例

接下來的示例來自 TFLearn(https://github.com/tflearn/tflearn),這是一個為 TensorFlow 提供了簡化的介面的庫。你可以看看,這裡有很多示例和預構建的運算和層。

  • 示例:https://github.com/tflearn/tflearn/tree/master/examples

  • 預構建的運算和層:http://tflearn.org/doc_index/#api

教程

TFLearn 快速入門。通過一個具體的機器學習任務學習 TFLearn 基礎。開發和訓練一個深度神經網路分類器。

  • 筆記:https://github.com/tflearn/tflearn/blob/master/tutorials/intro/quickstart.md

基礎

  • 線性迴歸,使用 TFLearn 實現線性迴歸:https://github.com/tflearn/tflearn/blob/master/examples/basics/linear_regression.py

  • 邏輯運算子。使用 TFLearn 實現邏輯運算子:https://github.com/tflearn/tflearn/blob/master/examples/basics/logical.py

  • 權重保持。儲存和還原一個模型:https://github.com/tflearn/tflearn/blob/master/examples/basics/weights_persistence.py

  • 微調。在一個新任務上微調一個預訓練的模型:https://github.com/tflearn/tflearn/blob/master/examples/basics/finetuning.py

  • 使用 HDF5。使用 HDF5 處理大型資料集:https://github.com/tflearn/tflearn/blob/master/examples/basics/use_hdf5.py

  • 使用 DASK。使用 DASK 處理大型資料集:https://github.com/tflearn/tflearn/blob/master/examples/basics/use_dask.py

計算機視覺

  • 多層感知器。一種用於 MNIST 分類任務的多層感知實現:https://github.com/tflearn/tflearn/blob/master/examples/images/dnn.py

  • 卷積網路(MNIST)。用於分類 MNIST 資料集的一種卷積神經網路實現:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_mnist.py

  • 卷積網路(CIFAR-10)。用於分類 CIFAR-10 資料集的一種卷積神經網路實現:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_cifar10.py

  • 網路中的網路。用於分類 CIFAR-10 資料集的 Network in Network 實現:https://github.com/tflearn/tflearn/blob/master/examples/images/network_in_network.py

  • Alexnet。將 Alexnet 應用於 Oxford Flowers 17 分類任務:https://github.com/tflearn/tflearn/blob/master/examples/images/alexnet.py

  • VGGNet。將 VGGNet 應用於 Oxford Flowers 17 分類任務:https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py

  • VGGNet Finetuning (Fast Training)。使用一個預訓練的 VGG 網路並將其約束到你自己的資料上,以便實現快速訓練:https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network_finetuning.py

  • RNN Pixels。使用 RNN(在畫素的序列上)分類影象:https://github.com/tflearn/tflearn/blob/master/examples/images/rnn_pixels.py

  • Highway Network。用於分類 MNIST 資料集的 Highway Network 實現:https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py

  • Highway Convolutional Network。用於分類 MNIST 資料集的 Highway Convolutional Network 實現:https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_highway_mnist.py

  • Residual Network (MNIST) (https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py).。應用於 MNIST 分類任務的一種瓶頸殘差網路(bottleneck residual network):https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py

  • Residual Network (CIFAR-10)。應用於 CIFAR-10 分類任務的一種殘差網路:https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py

  • Google Inception(v3)。應用於 Oxford Flowers 17 分類任務的谷歌 Inception v3 網路:https://github.com/tflearn/tflearn/blob/master/examples/images/googlenet.py

  • 自編碼器。用於 MNIST 手寫數字的自編碼器:https://github.com/tflearn/tflearn/blob/master/examples/images/autoencoder.py

自然語言處理

  • 迴圈神經網路(LSTM),應用 LSTM 到 IMDB 情感資料集分類任務:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm.py

  • 雙向 RNN(LSTM),將一個雙向 LSTM 應用到 IMDB 情感資料集分類任務:https://github.com/tflearn/tflearn/blob/master/examples/nlp/bidirectional_lstm.py

  • 動態 RNN(LSTM),利用動態 LSTM 從 IMDB 資料集分類可變長度文字:https://github.com/tflearn/tflearn/blob/master/examples/nlp/dynamic_lstm.py

  • 城市名稱生成,使用 LSTM 網路生成新的美國城市名:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_cityname.py

  • 莎士比亞手稿生成,使用 LSTM 網路生成新的莎士比亞手稿:https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_shakespeare.py

  • Seq2seq,seq2seq 迴圈網路的教學示例:https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py

  • CNN Seq,應用一個 1-D 卷積網路從 IMDB 情感資料集中分類詞序列:https://github.com/tflearn/tflearn/blob/master/examples/nlp/cnn_sentence_classification.py

強化學習

Atari Pacman 1-step Q-Learning,使用 1-step Q-learning 教一臺機器玩 Atari 遊戲:https://github.com/tflearn/tflearn/blob/master/examples/reinforcement_learning/atari_1step_qlearning.py

其他

Recommender-Wide&Deep Network,推薦系統中 wide & deep 網路的教學示例:https://github.com/tflearn/tflearn/blob/master/examples/others/recommender_wide_and_deep.py

Notebooks

  • Spiral Classification Problem,對史丹佛 CS231n spiral 分類難題的 TFLearn 實現:https://github.com/tflearn/tflearn/blob/master/examples/notebooks/spiral.ipynb

可延展的 TensorFlow

  • 層,與 TensorFlow 一起使用 TFLearn 層:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/layers.py

  • 訓練器,使用 TFLearn 訓練器類訓練任何 TensorFlow 圖:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/layers.py

  • Bulit-in Ops,連同 TensorFlow 使用 TFLearn built-in 操作:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/builtin_ops.py

  • Summaries,連同 TensorFlow 使用 TFLearn summarizers:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/summaries.py

  • Variables,連同 TensorFlow 使用 TFLearn Variables:https://github.com/tflearn/tflearn/blob/master/examples/extending_tensorflow/variables.py

  •  

相關文章