資源 | 數(shù)十種TensorFlow實(shí)現(xiàn)案例匯集:代碼+筆記

這是使用 TensorFlow 實(shí)現(xiàn)流行的機(jī)器學(xué)習(xí)算法的教程匯集序攘。本匯集的目標(biāo)是讓讀者可以輕松通過案例深入 TensorFlow。

這些案例適合那些想要清晰簡明的 TensorFlow 實(shí)現(xiàn)案例的初學(xué)者入录。本教程還包含了筆記和帶有注解的代碼矮烹。

項(xiàng)目地址:https://github.com/aymericdamien/TensorFlow-Examples

教程索引

0 - 先決條件

機(jī)器學(xué)習(xí)入門:

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

2鞠柄、MNIST 數(shù)據(jù)集入門

3继控、筆記: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 - 神經(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

動(dòng)態(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

4 - 實(shí)用技術(shù)

保存和恢復(fù)模型

筆記: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

數(shù)據(jù)集

一些案例需要 MNIST 數(shù)據(jù)集進(jìn)行訓(xùn)練和測試械馆。不要擔(dān)心,運(yùn)行這些案例時(shí)武通,該數(shù)據(jù)集會(huì)被自動(dòng)下載下來(使用 input_data.py)霹崎。MNIST 是一個(gè)手寫數(shù)字的數(shù)據(jù)庫,查看這個(gè)筆記了解關(guān)于該數(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/

更多案例

接下來的示例來自 TFLearn(https://github.com/tflearn/tflearn)冶忱,這是一個(gè)為 TensorFlow 提供了簡化的接口的庫尾菇。你可以看看,這里有很多示例和預(yù)構(gòu)建的運(yùn)算和層囚枪。

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

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

教程

TFLearn 快速入門派诬。通過一個(gè)具體的機(jī)器學(xué)習(xí)任務(wù)學(xué)習(xí) TFLearn 基礎(chǔ)。開發(fā)和訓(xùn)練一個(gè)深度神經(jīng)網(wǎng)絡(luò)分類器眶拉。

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

基礎(chǔ)

線性回歸千埃,使用 TFLearn 實(shí)現(xiàn)線性回歸:https://github.com/tflearn/tflearn/blob/master/examples/basics/linear_regression.py

邏輯運(yùn)算符憔儿。使用 TFLearn 實(shí)現(xiàn)邏輯運(yùn)算符:https://github.com/tflearn/tflearn/blob/master/examples/basics/logical.py

權(quán)重保持忆植。保存和還原一個(gè)模型:https://github.com/tflearn/tflearn/blob/master/examples/basics/weights_persistence.py

微調(diào)。在一個(gè)新任務(wù)上微調(diào)一個(gè)預(yù)訓(xùn)練的模型: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

計(jì)算機(jī)視覺

多層感知器耀里。一種用于 MNIST 分類任務(wù)的多層感知實(shí)現(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ò)實(shí)現(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ò)實(shí)現(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 實(shí)現(xiàn):https://github.com/tflearn/tflearn/blob/master/examples/images/network_in_network.py

Alexnet。將 Alexnet 應(yīng)用于 Oxford Flowers 17 分類任務(wù):https://github.com/tflearn/tflearn/blob/master/examples/images/alexnet.py

VGGNet咙鞍。將 VGGNet 應(yīng)用于 Oxford Flowers 17 分類任務(wù):https://github.com/tflearn/tflearn/blob/master/examples/images/vgg_network.py

VGGNet Finetuning (Fast Training)房官。使用一個(gè)預(yù)訓(xùn)練的 VGG 網(wǎng)絡(luò)并將其約束到你自己的數(shù)據(jù)上,以便實(shí)現(xiàn)快速訓(xù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 實(shí)現(xiàn):https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py

Highway Convolutional Network蛮拔。用于分類 MNIST 數(shù)據(jù)集的 Highway Convolutional Network 實(shí)現(xiàn):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).舷丹。應(yīng)用于 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)。應(yīng)用于 CIFAR-10 分類任務(wù)的一種殘差網(wǎng)絡(luò):https://github.com/tflearn/tflearn/blob/master/examples/images/residual_network_cifar10.py

Google Inception(v3)最筒。應(yīng)用于 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

自然語言處理

循環(huán)神經(jīng)網(wǎng)絡(luò)(LSTM)湿颅,應(yīng)用 LSTM 到 IMDB 情感數(shù)據(jù)集分類任務(wù):https://github.com/tflearn/tflearn/blob/master/examples/nlp/lstm.py

雙向 RNN(LSTM),將一個(gè)雙向 LSTM 應(yīng)用到 IMDB 情感數(shù)據(jù)集分類任務(wù):https://github.com/tflearn/tflearn/blob/master/examples/nlp/bidirectional_lstm.py

動(dòng)態(tài) RNN(LSTM)粥诫,利用動(dòng)態(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ò)的教學(xué)示例:https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py

CNN Seq劝堪,應(yīng)用一個(gè) 1-D 卷積網(wǎng)絡(luò)從 IMDB 情感數(shù)據(jù)集中分類詞序列:https://github.com/tflearn/tflearn/blob/master/examples/nlp/cnn_sentence_classification.py

強(qiáng)化學(xué)習(xí)

Atari Pacman 1-step Q-Learning,使用 1-step Q-learning 教一臺(tái)機(jī)器玩 Atari 游戲:https://github.com/tflearn/tflearn/blob/master/examples/reinforcement_learning/atari_1step_qlearning.py

其他

Recommender-Wide&Deep Network揉稚,推薦系統(tǒng)中 wide & deep 網(wǎng)絡(luò)的教學(xué)示例:https://github.com/tflearn/tflearn/blob/master/examples/others/recommender_wide_and_deep.py

Notebooks

Spiral Classification Problem秒啦,對斯坦福 CS231n spiral 分類難題的 TFLearn 實(shí)現(xiàn):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

訓(xùn)練器搀玖,使用 TFLearn 訓(xùn)練器類訓(xùn)練任何 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)系作者
  • 序言:七十年代末芳来,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子猜拾,更是在濱河造成了極大的恐慌即舌,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,576評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件挎袜,死亡現(xiàn)場離奇詭異顽聂,居然都是意外死亡肥惭,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,515評論 3 399
  • 文/潘曉璐 我一進(jìn)店門紊搪,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蜜葱,“玉大人,你說我怎么就攤上這事耀石∏6冢” “怎么了?”我有些...
    開封第一講書人閱讀 168,017評論 0 360
  • 文/不壞的土叔 我叫張陵滞伟,是天一觀的道長揭鳞。 經(jīng)常有香客問我,道長梆奈,這世上最難降的妖魔是什么汹桦? 我笑而不...
    開封第一講書人閱讀 59,626評論 1 296
  • 正文 為了忘掉前任,我火速辦了婚禮鉴裹,結(jié)果婚禮上舞骆,老公的妹妹穿的比我還像新娘。我一直安慰自己径荔,他們只是感情好督禽,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,625評論 6 397
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著总处,像睡著了一般狈惫。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上鹦马,一...
    開封第一講書人閱讀 52,255評論 1 308
  • 那天胧谈,我揣著相機(jī)與錄音,去河邊找鬼荸频。 笑死菱肖,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的旭从。 我是一名探鬼主播稳强,決...
    沈念sama閱讀 40,825評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼和悦!你這毒婦竟也來了退疫?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,729評論 0 276
  • 序言:老撾萬榮一對情侶失蹤鸽素,失蹤者是張志新(化名)和其女友劉穎褒繁,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體馍忽,經(jīng)...
    沈念sama閱讀 46,271評論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡棒坏,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,363評論 3 340
  • 正文 我和宋清朗相戀三年燕差,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片俊抵。...
    茶點(diǎn)故事閱讀 40,498評論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡谁不,死狀恐怖坐梯,靈堂內(nèi)的尸體忽然破棺而出徽诲,到底是詐尸還是另有隱情,我是刑警寧澤吵血,帶...
    沈念sama閱讀 36,183評論 5 350
  • 正文 年R本政府宣布谎替,位于F島的核電站,受9級特大地震影響蹋辅,放射性物質(zhì)發(fā)生泄漏钱贯。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,867評論 3 333
  • 文/蒙蒙 一侦另、第九天 我趴在偏房一處隱蔽的房頂上張望秩命。 院中可真熱鬧,春花似錦褒傅、人聲如沸弃锐。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,338評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽霹菊。三九已至,卻和暖如春支竹,著一層夾襖步出監(jiān)牢的瞬間旋廷,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,458評論 1 272
  • 我被黑心中介騙來泰國打工礼搁, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留饶碘,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,906評論 3 376
  • 正文 我出身青樓馒吴,卻偏偏與公主長得像熊镣,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子募书,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,507評論 2 359

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