(轉(zhuǎn))TensorFlow的55個經(jīng)典案例

轉(zhuǎn)自https://mp.weixin.qq.com/s/Qdo1vks94tbGkzXEiuQV7w

導語:本文是TensorFlow實現(xiàn)流行機器學習算法的教程匯集寝优,目標是讓讀者可以輕松通過清晰簡明的案例深入了解 TensorFlow。這些案例適合那些想要實現(xiàn)一些 TensorFlow 案例的初學者枫耳。本教程包含還包含筆記和帶有注解的代碼乏矾。

第一步:給TF新手的教程指南

1:tf初學者需要明白的入門準備

機器學習入門筆記:

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

MNIST 數(shù)據(jù)集入門筆記

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

2:tf初學者需要了解的入門基礎(chǔ)

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

3:tf初學者需要掌握的基本模型

最近鄰:

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

4:tf初學者需要嘗試的神經(jīng)網(wǎng)絡(luò)

多層感知器:

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

卷積神經(jīng)網(wǎng)絡(luò):

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

循環(huán)神經(jīng)網(wǎng)絡(luò)(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

雙向循環(huán)神經(jīng)網(wǎng)絡(luò)(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

動態(tài)循環(huán)神經(jīng)網(wǎng)絡(luò)(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

5:tf初學者需要精通的實用技術(shù)

保存和恢復模型

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:tf初學者需要的懂得的多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

6:案例需要的數(shù)據(jù)集

有一些案例需要 MNIST 數(shù)據(jù)集進行訓練和測試。運行這些案例時迁杨,該數(shù)據(jù)集會被自動下載下來(使用 input_data.py)钻心。

MNIST數(shù)據(jù)集筆記:https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/0_Prerequisite/mnist_dataset_intro.ipynb

官方網(wǎng)站:http://yann.lecun.com/exdb/mnist/

第二步:為TF新手準備的各個類型的案例、模型和數(shù)據(jù)集

初步了解:TFLearn TensorFlow

接下來的示例來自TFLearn铅协,這是一個為 TensorFlow 提供了簡化的接口的庫捷沸。里面有很多示例和預構(gòu)建的運算和層。

使用教程:TFLearn 快速入門警医。通過一個具體的機器學習任務(wù)學習 TFLearn 基礎(chǔ)亿胸。開發(fā)和訓練一個深度神經(jīng)網(wǎng)絡(luò)分類器。

TFLearn地址:https://github.com/tflearn/tflearn

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

預構(gòu)建的運算和層:http://tflearn.org/doc_index/#api

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

基礎(chǔ)模型以及數(shù)據(jù)集

線性回歸预皇,使用 TFLearn 實現(xiàn)線性回歸

https://github.com/tflearn/tflearn/blob/master/examples/basics/linear_regression.py

邏輯運算符侈玄。使用 TFLearn 實現(xiàn)邏輯運算符

https://github.com/tflearn/tflearn/blob/master/examples/basics/logical.py

權(quán)重保持。保存和還原一個模型

https://github.com/tflearn/tflearn/blob/master/examples/basics/weights_persistence.py

微調(diào)吟温。在一個新任務(wù)上微調(diào)一個預訓練的模型

https://github.com/tflearn/tflearn/blob/master/examples/basics/finetuning.py

使用 HDF5序仙。使用 HDF5 處理大型數(shù)據(jù)集

https://github.com/tflearn/tflearn/blob/master/examples/basics/use_hdf5.py

使用 DASK。使用 DASK 處理大型數(shù)據(jù)集

https://github.com/tflearn/tflearn/blob/master/examples/basics/use_dask.py

計算機視覺模型及數(shù)據(jù)集

多層感知器鲁豪。一種用于 MNIST 分類任務(wù)的多層感知實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/dnn.py

卷積網(wǎng)絡(luò)(MNIST)潘悼。用于分類 MNIST 數(shù)據(jù)集的一種卷積神經(jīng)網(wǎng)絡(luò)實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_mnist.py

卷積網(wǎng)絡(luò)(CIFAR-10)。用于分類 CIFAR-10 數(shù)據(jù)集的一種卷積神經(jīng)網(wǎng)絡(luò)實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_cifar10.py

網(wǎng)絡(luò)中的網(wǎng)絡(luò)爬橡。用于分類 CIFAR-10 數(shù)據(jù)集的 Network in Network 實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/network_in_network.py

Alexnet治唤。將 Alexnet 應用于 Oxford Flowers 17 分類任務(wù)

https://github.com/tflearn/tflearn/blob/master/examples/images/alexnet.py

VGGNet。將 VGGNet 應用于 Oxford Flowers 17 分類任務(wù)

https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py

VGGNet Finetuning (Fast Training)糙申。使用一個預訓練的 VGG 網(wǎng)絡(luò)并將其約束到你自己的數(shù)據(jù)上宾添,以便實現(xiàn)快速訓練

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 數(shù)據(jù)集的 Highway Network 實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py

Highway Convolutional Network缕陕。用于分類 MNIST 數(shù)據(jù)集的 Highway Convolutional Network 實現(xiàn)

https://github.com/tflearn/tflearn/blob/master/examples/images/convnet_highway_mnist.py

Residual Network (MNIST) 。應用于 MNIST 分類任務(wù)的一種瓶頸殘差網(wǎng)絡(luò)(bottleneck residual network)

https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_mnist.py

Residual Network (CIFAR-10)疙挺。應用于 CIFAR-10 分類任務(wù)的一種殘差網(wǎng)絡(luò)

https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py

Google Inception(v3)扛邑。應用于 Oxford Flowers 17 分類任務(wù)的谷歌 Inception v3 網(wǎng)絡(luò)

https://github.com/tflearn/tflearn/blob/master/examples/images/googlenet.py

自編碼器。用于 MNIST 手寫數(shù)字的自編碼器

https://github.com/tflearn/tflearn/blob/master/examples/images/autoencoder.py

自然語言處理模型及數(shù)據(jù)集

循環(huán)神經(jīng)網(wǎng)絡(luò)(LSTM)铐然,應用 LSTM 到 IMDB 情感數(shù)據(jù)集分類任

https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm.py

雙向 RNN(LSTM)蔬崩,將一個雙向 LSTM 應用到 IMDB 情感數(shù)據(jù)集分類任務(wù):

https://github.com/tflearn/tflearn/blob/master/examples/nlp/bidirectional_lstm.py

動態(tài) RNN(LSTM)恶座,利用動態(tài) LSTM 從 IMDB 數(shù)據(jù)集分類可變長度文本:

https://github.com/tflearn/tflearn/blob/master/examples/nlp/dynamic_lstm.py

城市名稱生成,使用 LSTM 網(wǎng)絡(luò)生成新的美國城市名:

https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_cityname.py

莎士比亞手稿生成舱殿,使用 LSTM 網(wǎng)絡(luò)生成新的莎士比亞手稿:

https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm_generator_shakespeare.py

Seq2seq奥裸,seq2seq 循環(huán)網(wǎng)絡(luò)的教學示例:

https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py

CNN Seq,應用一個 1-D 卷積網(wǎng)絡(luò)從 IMDB 情感數(shù)據(jù)集中分類詞序列

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

第三步:為TF新手準備的其他方面內(nèi)容

Recommender-Wide&Deep Network湾宙,推薦系統(tǒng)中 wide & deep 網(wǎng)絡(luò)的教學示例:

https://github.com/tflearn/tflearn/blob/master/examples/others/recommender_wide_and_deep.py

Spiral Classification Problem,對斯坦福 CS231n spiral 分類難題的 TFLearn 實現(xiàn):

https://github.com/tflearn/tflearn/blob/master/examples/notebooks/spiral.ipynb

層冈绊,與 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市毅该,隨后出現(xiàn)的幾起案子博秫,更是在濱河造成了極大的恐慌,老刑警劉巖眶掌,帶你破解...
    沈念sama閱讀 218,941評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件挡育,死亡現(xiàn)場離奇詭異,居然都是意外死亡朴爬,警方通過查閱死者的電腦和手機即寒,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來召噩,“玉大人母赵,你說我怎么就攤上這事【叩危” “怎么了凹嘲?”我有些...
    開封第一講書人閱讀 165,345評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長构韵。 經(jīng)常有香客問我施绎,道長,這世上最難降的妖魔是什么贞绳? 我笑而不...
    開封第一講書人閱讀 58,851評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮致稀,結(jié)果婚禮上冈闭,老公的妹妹穿的比我還像新娘。我一直安慰自己抖单,他們只是感情好萎攒,可當我...
    茶點故事閱讀 67,868評論 6 392
  • 文/花漫 我一把揭開白布遇八。 她就那樣靜靜地躺著,像睡著了一般耍休。 火紅的嫁衣襯著肌膚如雪刃永。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,688評論 1 305
  • 那天羊精,我揣著相機與錄音斯够,去河邊找鬼。 笑死喧锦,一個胖子當著我的面吹牛读规,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播燃少,決...
    沈念sama閱讀 40,414評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼束亏,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了阵具?” 一聲冷哼從身側(cè)響起碍遍,我...
    開封第一講書人閱讀 39,319評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎阳液,沒想到半個月后怕敬,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,775評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡趁舀,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年赖捌,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片矮烹。...
    茶點故事閱讀 40,096評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡越庇,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出奉狈,到底是詐尸還是另有隱情卤唉,我是刑警寧澤,帶...
    沈念sama閱讀 35,789評論 5 346
  • 正文 年R本政府宣布仁期,位于F島的核電站桑驱,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏跛蛋。R本人自食惡果不足惜熬的,卻給世界環(huán)境...
    茶點故事閱讀 41,437評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望赊级。 院中可真熱鬧押框,春花似錦、人聲如沸理逊。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至兑徘,卻和暖如春刚盈,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背挂脑。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評論 1 271
  • 我被黑心中介騙來泰國打工藕漱, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人最域。 一個月前我還...
    沈念sama閱讀 48,308評論 3 372
  • 正文 我出身青樓谴分,卻偏偏與公主長得像,于是被迫代替她去往敵國和親镀脂。 傳聞我的和親對象是個殘疾皇子牺蹄,可洞房花燭夜當晚...
    茶點故事閱讀 45,037評論 2 355

推薦閱讀更多精彩內(nèi)容