一網打盡!深度學習100+經典模型TensorFlow與Pytorch代碼實現大集合

2021-02-21 專知

【導讀】深度學習在過去十年獲得了極大進展,出現很多新的模型,並且伴隨TensorFlow和Pytorch框架的出現,有很多實現,但對於初學者和很多從業人員,如何選擇合適的實現,是個選擇。rasbt在Github上整理了關於深度學習模型TensorFlow和Pytorch代碼實現集合,含有100個,各種各樣的深度學習架構,模型,和技巧的集合Jupyter Notebooks,從基礎的邏輯回歸到神經網絡到CNN到GNN等,可謂一網打盡,值得收藏!


地址:

https://github.com/rasbt/deeplearning-models

傳統機器學習


感知器 Perceptron
   [TensorFlow 1: GitHub | Nbviewer]

https://github.com/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/basic-ml/perceptron.ipynb
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/basic-ml/perceptron.ipynb

邏輯回歸 Logistic Regression
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/basic-ml/logistic-regression.ipynb
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/basic-ml/logistic-regression.ipynb

Softmax Regression (Multinomial Logistic Regression)
   [TensorFlow 1: GitHub | Nbviewer]

https://github.com/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/basic-ml/softmax-regression.ipynb
   [PyTorch: GitHub | Nbviewer]

https://github.com/rasbt/deeplearning-models/blob/master/pytorch_ipynb/basic-ml/softmax-regression.ipynb

Softmax Regression with MLxtend's plot_decision_regions on Iris
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/basic-ml/softmax-regression-mlxtend-1.ipynb

多層感知器


多層感知器 Multilayer Perceptron
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/mlp/mlp-basic.ipynb
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/mlp/mlp-basic.ipynb

帶Dropout的多層感知器 Multilayer Perceptron with Dropout
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

具有批處理規範化的多層感知器 Multilayer Perceptron with Batch Normalization
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Multilayer Perceptron with Backpropagation from Scratch
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

卷積神經網絡

基礎

卷積神經網絡 Convolutional Neural Network
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/cnn/cnn-basic.ipynb
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/cnn/cnn-basic.ipynb

Convolutional Neural Network with He Initialization
   [PyTorch: GitHub | Nbviewer]

ConceptsFully ConvolutionalLeNet

LeNet-5 on MNIST
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/cnn/cnn-lenet5-mnist.ipynb

LeNet-5 on CIFAR-10
   [PyTorch: GitHub | Nbviewer]

LeNet-5 on QuickDraw
   [PyTorch: GitHub | Nbviewer]

AlexNet

VGG

Convolutional Neural Network VGG-16
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/cnn/cnn-vgg16.ipynb
   [PyTorch: GitHub | Nbviewer]

VGG-16 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

Convolutional Neural Network VGG-19
   [PyTorch: GitHub | Nbviewer]

DenseNet

DenseNet-121 Digit Classifier Trained on MNIST
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/cnn/cnn-densenet121-mnist.ipynb

DenseNet-121 Image Classifier Trained on CIFAR-10
   [PyTorch: GitHub | Nbviewer]

ResNet

ResNet and Residual Blocks
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/cnn/resnet-ex-1.ipynb

ResNet-18 Digit Classifier Trained on MNIST
   [PyTorch: GitHub | Nbviewer]

ResNet-18 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

ResNet-34 Digit Classifier Trained on MNIST
   [PyTorch: GitHub | Nbviewer]

ResNet-34 Object Classifier Trained on QuickDraw
   [PyTorch: GitHub | Nbviewer]

ResNet-34 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

ResNet-50 Digit Classifier Trained on MNIST
   [PyTorch: GitHub | Nbviewer]

ResNet-50 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

ResNet-101 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

ResNet-101 Trained on CIFAR-10
   [PyTorch: GitHub | Nbviewer]

ResNet-152 Gender Classifier Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

Network in Network

歸一化層 Normalization Layers

BatchNorm before and after Activation for Network-in-Network CIFAR-10 Classifier
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/cnn/nin-cifar10_batchnorm.ipynb

Filter Response Normalization for Network-in-Network CIFAR-10 Classifier
   [PyTorch: GitHub | Nbviewer]

度量學習 Metric Learning自編碼器 Autoencoders

全連接自編碼器 Fully-connected Autoencoders

Autoencoder (MNIST)
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/autoencoder/ae-basic.ipynb
   [PyTorch: GitHub | Nbviewer]

Autoencoder (MNIST) + Scikit-Learn Random Forest Classifier
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoders

Convolutional Autoencoder with Deconvolutions / Transposed Convolutions
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoder with Deconvolutions and Continuous Jaccard Distance
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoder with Deconvolutions (without pooling operations)
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoder with Nearest-neighbor Interpolation
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoder with Nearest-neighbor Interpolation -- Trained on CelebA
   [PyTorch: GitHub | Nbviewer]

Convolutional Autoencoder with Nearest-neighbor Interpolation -- Trained on Quickdraw
   [PyTorch: GitHub | Nbviewer]

Variational AutoencodersConditional Variational Autoencoders

Conditional Variational Autoencoder (with labels in reconstruction loss)
   [PyTorch: GitHub | Nbviewer]

Conditional Variational Autoencoder (without labels in reconstruction loss)
   [PyTorch: GitHub | Nbviewer]

Convolutional Conditional Variational Autoencoder (with labels in reconstruction loss)
   [PyTorch: GitHub | Nbviewer]

Convolutional Conditional Variational Autoencoder (without labels in reconstruction loss)
   [PyTorch: GitHub | Nbviewer]

生成式對抗網絡 Generative Adversarial Networks (GANs)

Fully Connected GAN on MNIST
   [TensorFlow 1: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/tensorflow1_ipynb/gan/gan.ipynb
   [PyTorch: GitHub | Nbviewer]

Fully Connected Wasserstein GAN on MNIST
   [PyTorch: GitHub | Nbviewer]

Convolutional GAN on MNIST
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Convolutional GAN on MNIST with Label Smoothing
   [TensorFlow 1: GitHub | Nbviewer]
   [PyTorch: GitHub | Nbviewer]

Convolutional Wasserstein GAN on MNIST
   [PyTorch: GitHub | Nbviewer]

圖神經網絡 Graph Neural Networks (GNNs)

Most Basic Graph Neural Network with Gaussian Filter on MNIST
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/gnn/gnn-basic-1.ipynb

Basic Graph Neural Network with Edge Prediction on MNIST
   [PyTorch: GitHub | Nbviewer]

Basic Graph Neural Network with Spectral Graph Convolution on MNIST
   [PyTorch: GitHub | Nbviewer]

循環神經網絡 Recurrent Neural Networks (RNNs)

Many-to-one: Sentiment Analysis / Classification

A simple single-layer RNN (IMDB)
   [PyTorch: GitHub | Nbviewer]

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/rnn/rnn_simple_imdb.ipynb

A simple single-layer RNN with packed sequences to ignore padding characters (IMDB)
   [PyTorch: GitHub | Nbviewer]

RNN with LSTM cells (IMDB)
   [PyTorch: GitHub | Nbviewer]

RNN with LSTM cells (IMDB) and pre-trained GloVe word vectors
   [PyTorch: GitHub | Nbviewer]

RNN with LSTM cells and Own Dataset in CSV Format (IMDB)
   [PyTorch: GitHub | Nbviewer]

RNN with GRU cells (IMDB)
   [PyTorch: GitHub | Nbviewer]

Multilayer bi-directional RNN (IMDB)
   [PyTorch: GitHub | Nbviewer]

Bidirectional Multi-layer RNN with LSTM with Own Dataset in CSV Format (AG News)
   [PyTorch: GitHub | Nbviewer]

Bidirectional Multi-layer RNN with LSTM with Own Dataset in CSV Format (Yelp Review Polarity)
   [PyTorch: GitHub | Nbviewer]

Bidirectional Multi-layer RNN with LSTM with Own Dataset in CSV Format (Amazon Review Polarity)
   [PyTorch: GitHub | Nbviewer]

Many-to-Many / Sequence-to-SequenceOrdinal Regression

Ordinal Regression CNN -- CORAL w. ResNet34 on AFAD-Lite
   [PyTorch: GitHub | Nbviewer]

Ordinal Regression CNN -- Niu et al. 2016 w. ResNet34 on AFAD-Lite
   [PyTorch: GitHub | Nbviewer]

Ordinal Regression CNN -- Beckham and Pal 2016 w. ResNet34 on AFAD-Lite
   [PyTorch: GitHub | Nbviewer]

Tips and Tricks

Cyclical Learning Rate
   [PyTorch: GitHub | Nbviewer]

Annealing with Increasing the Batch Size (w. CIFAR-10 & AlexNet)
   [PyTorch: GitHub | Nbviewer]

Gradient Clipping (w. MLP on MNIST)
   [PyTorch: GitHub | Nbviewer]

 遷移學習 Transfer Learning

   [PyTorch: GitHub | Nbviewer

https://nbviewer.jupyter.org/github/rasbt/deeplearning-models/blob/master/pytorch_ipynb/transfer/transferlearning-vgg16-cifar10-1.ipynb

PyTorch Workflows and MechanicsCustom Datasets

Custom Data Loader Example for PNG Files
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- CSV files converted to HDF5
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- Face Images from CelebA
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- Drawings from Quickdraw
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- Drawings from the Street View House Number (SVHN) Dataset
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- Asian Face Dataset (AFAD)
   [PyTorch: GitHub | Nbviewer]

Using PyTorch Dataset Loading Utilities for Custom Datasets -- Dating Historical Color Images
   [PyTorch: GitHub | Nbviewer]

Training and Preprocessing

Generating Validation Set Splits
[PyTorch]: GitHub | Nbviewer]

Dataloading with Pinned Memory
   [PyTorch: GitHub | Nbviewer]

Standardizing Images
   [PyTorch: GitHub | Nbviewer]

Image Transformation Examples
   [PyTorch: GitHub | Nbviewer]

Char-RNN with Own Text File
   [PyTorch: GitHub | Nbviewer]

Sentiment Classification RNN with Own CSV File
   [PyTorch: GitHub | Nbviewer]

Parallel ComputingOther

Sequential API and hooks
   [PyTorch: GitHub | Nbviewer]

Weight Sharing Within a Layer
   [PyTorch: GitHub | Nbviewer]

Plotting Live Training Performance in Jupyter Notebooks with just Matplotlib
   [PyTorch: GitHub | Nbviewer]

AutogradTensorFlow Workflows and MechanicsCustom Datasets

Chunking an Image Dataset for Minibatch Training using NumPy NPZ Archives
   [TensorFlow 1: GitHub | Nbviewer]

Storing an Image Dataset for Minibatch Training using HDF5
   [TensorFlow 1: GitHub | Nbviewer]

Using Input Pipelines to Read Data from TFRecords Files
   [TensorFlow 1: GitHub | Nbviewer]

Using Queue Runners to Feed Images Directly from Disk
   [TensorFlow 1: GitHub | Nbviewer]

Using TensorFlow's Dataset API
   [TensorFlow 1: GitHub | Nbviewer]

Training and Preprocessing

便捷查看下載,請關注專知公眾號(點擊上方藍色專知關注)

專知,專業可信的人工智慧知識分發,讓認知協作更快更好!歡迎註冊登錄專知www.zhuanzhi.ai,獲取5000+AI主題乾貨知識資料!歡迎微信掃一掃加入專知人工智慧知識星球群,獲取最新AI專業乾貨知識教程視頻資料和與專家交流諮詢

點擊「閱讀原文」,了解使用專知,查看5000+AI主題知識資料

相關焦點

  • TensorFlow+PyTorch深度學習大寶庫
    整編自:https://github.com/rasbt/deeplearning-models昨日,猿妹例行打開GitHub Trending,排行第一的項目成功引起了我的注意——deeplearning-models該項目是Jupyter Notebook中TensorFlow和PyTorch的各種深度學習架構
  • TensorFlow與PyTorch之爭,哪個框架最適合深度學習
    那麼究竟哪種框架最適宜自己手邊的深度學習項目呢?本文作者從這兩種框架各自的功能效果、優缺點以及安裝、版本更新等諸多方面給出了自己的建議。如果你在讀這篇文章,那麼你可能已經開始了自己的深度學習之旅。如果你對這一領域還不是很熟悉,那麼簡單來說,深度學習使用了「人工神經網絡」,這是一種類似大腦的特殊架構,這個領域的發展目標是開發出能解決真實世界問題的類人計算機。
  • GitHub趨勢榜第一:TensorFlow+PyTorch深度學習資源大匯總
    來源:Github編輯整理:元子【新智元導讀】該項目是Jupyter Notebook中TensorFlow和PyTorch的各種深度學習架構,模型和技巧的集合。本文搜集整理了Jupyter Notebook中TensorFlow和PyTorch的各種深度學習架構,模型和技巧,內容非常豐富,適用於Python 3.7,適合當做工具書。大家可以將內容按照需要進行分割,列印出來,或者做成電子書等,隨時查閱。
  • TensorFlow 與 PyTorch 之爭
    谷歌的 Tensorflow 與 Facebook 的 PyTorch 一直是頗受社區歡迎的兩種深度學習框架。那麼究竟哪種框架最適宜自己手邊的深度學習項目呢?本文作者從這兩種框架各自的功能效果、優缺點以及安裝、版本更新等諸多方面給出了自己的建議。如果你在讀這篇文章,那麼你可能已經開始了自己的深度學習之旅。
  • 深度學習環境配置指南:Pytorch、TensorFlow、Keras
    導讀本文介紹了作者使用RTX3090進行深度學習環境配置pytorch、tensorflow、keras等的詳細過程及代碼。筆者中山大學研究生,醫學生+計科學生的集合體,機器學習愛好者。-7.2.1.4-cp36-none-linux_x86_64.whl tensorflow_estimator-1.15.1-py2.py3-none-any.whl nvidia_tensorboard-1.15.0+nv20.10-py3-none-any.whlnvidia_tensorflow-1.15.4+nv20.10-cp36-cp36m-linux_x86_64.whl -i http
  • 跨越重重「障礙」,我從 PyTorch 轉換為了 TensorFlow Lite
    我最近不得不將深度學習模型(MobileNetV2 的變體)從 PyTorch 轉換為 TensorFlow Lite。這是一個漫長而複雜的旅程。需要跨越很多障礙才能成功。我發現自己從 StackOverflow 帖子和 GitHub 的問題中搜集了一些信息。我的目標是分享我的經驗,以幫助其他像我一樣「迷失」的人。免責聲明:本文並非關於如何正確進行轉換的指南。
  • 基於TensorFlow的深度學習實戰
    毫不誇張得說,TensorFlow的流行讓深度學習門檻變得越來越低,只要你有Python和機器學習基礎,入門和使用神經網絡模型變得非常簡單。TensorFlow簡介如前所述,TensorFlow是一個深度學習庫,使用這一框架,可以用來構建和測試深度神經網絡。深度學習讓我們能夠以極高的準確性構建複雜的應用程式。
  • 對比 | TensorFlow VS PyTorch下的深度學習框架之爭
    source:https://thegradient.pub/state-of-ml-frameworks-2019-pytorch-dominates-research-tensorflow-dominates-industry/對於廣大深度學習行業從業者而言,熟練掌握一種或多種深度學習框架,是日常煉丹的必備技能之一。
  • RTX 3090 的深度學習環境配置指南:Pytorch、TensorFlow、Keras
    導讀本文介紹了作者使用RTX3090進行深度學習環境配置pytorch、tensorflow、keras等的詳細過程及代碼。筆者中山大學研究生,醫學生+計科學生的集合體,機器學習愛好者。-7.2.1.4-cp36-none-linux_x86_64.whl tensorflow_estimator-1.15.1-py2.py3-none-any.whl nvidia_tensorboard-1.15.0+nv20.10-py3-none-any.whlnvidia_tensorflow-1.15.4+nv20.10-cp36-cp36m-linux_x86_64.whl -i http
  • 深度學習TensorFlow實現集合
    【導讀】該項目使用Tensflow實現了一些一些深度學習的算法,幫助新手更快的上手。
  • 深度學習與 Spark 和 TensorFlow
    本文中,我們將演示如何使用TensorFlow和Spark一起訓練和應用深度學習模型。你可能會困惑:在最高性能深度學習實現還是單節點的當下, Spark 的用處在哪裡?為了回答這個問題,我們將會演示兩個例子並解釋如何使用 Spark 和機器集群搭配 TensorFlow 來提高深度學習的管道數。
  • 模型秒變API只需一行代碼,支持TensorFlow等框架
    專注於機器學習應用的人們知道,從訓練好的模型到實際的工業生產工具還有一定的距離。其中工作量很大的地方在於將模型打包,預留 API 接口,並和現有的生產系統相結合。近日,GitHub 上有了這樣一個項目,能夠讓用戶一行代碼將任意模型打包為 API。這一工具無疑能夠幫助開發者在實際的生產應用中快速部署模型。
  • 乾貨 | tensorflow模型導出與OpenCV DNN中使用
    ,支持基於深度學習模塊前饋網絡運行、實現圖像與視頻場景中的其模型導入與加載的相關API支持以下深度學習框架tensorflow - readNetFromTensorflowcaffe - readNetFromCaffepytorch - readNetFromTorchdarknet - readNetFromDarknet
  • Google深度學習TensorFlow最好的入門文章!
    這是一個3小時的課程(視頻+ppt),本課程為開發者提供簡要的深度學習基礎知識的介紹,以及 TensorFlow 的教學。深度學習(又名神經網絡)是建立機器學習模型的流行方法,許多開發者使用深度學習實現了他們的想法。如果你想學會深度學習,但又缺少時間,我深有同感。我大學時有一位數學老師,會對我大喊大叫:「Görner!積分在幼兒園就教過了!」
  • Seq2seq強化學習實戰 (Pytorch, Tensorflow, Theano)
    【導讀】本文是Kirti Bakshi在1月14日寫的關於其強化學習課程的一個介紹,作者首先簡單介紹了機器學習的缺點,以及為什麼使用深度學習。
  • 基於tensorRT實現TensorFlow模型的高效推理
    總篇58篇 2019年第32篇一、引言  深度學習中網絡模型的推理速度直接決定了其應用場景
  • 深度學習TensorFlow的55個經典案例
    人工智慧大數據與深度學習  公眾號: weic2c
  • 深度學習基礎(十):TensorFlow 2.x模型的驗證、正則化和回調
    深度學習背後的數學思想Tensorflow2實現YOLOv3目標檢測開發機器學習模型時的一個常見問題是過擬合。此外,對模型進行泛化是一項實際需求。否則,如果您無法使用機器學習模型來訓練模型所依據的數據,而無法成功地進行預測,那麼該方法又有什麼用呢?通過模型選擇和正則化來實現泛化和避免過度擬合。Tensorflow 2.x提供了 回調 函數的功能,工程師可以通過該 功能在培訓進行時根據保留的驗證集監視模型的性能。
  • 手把手教你由TensorFlow上手PyTorch(附代碼)
    所以你需要不時查看原始碼:http://pytorch.org/tutorials/。 當然,目前網絡上已有了一些 PyTorch 論壇,你可以在其中詢問相關的問題,並很快得到回覆:https://discuss.pytorch.org/。
  • TensorRT 加速 PyTorch 模型基本方法
    但是TensorRT坑爹的地方在於,有些模型操作是不支持的、又或者就算支持但是支持並不完善,對於這些難題,要麼自己寫插件,要麼就只能等待官方的更新了。現在我們訓練深度學習模型主流的框架有tensorflow,pytorch,mxnet,caffe等。