本文收集了大量基於 PyTorch 實現的代碼連結,其中有適用於深度學習新手的“入門指導系列”,也有適用於老司機的論文代碼實現,包括 Attention Based CNN、A3C、WGAN等等。所有代碼均按照所屬技術領域分類,包括機器視覺/映像相關、自然語言處理相關、強化學習相關等等。所以如果你打算入手這風行一世的 PyTorch 技術,那麼就快快收藏本文吧。
PyTorch 是什麼。
PyTorch即 Torch 的 Python 版本。Torch 是由 Facebook 發布的深度學習架構,因支援動態定義計算圖,相比於 Tensorflow 使用起來更為靈活方便,特別適合中小型機器學習項目和深度學習初學者。但因為 Torch 的開發語言是Lua,導致它在國內一直很小眾。所以,在千呼萬喚下,PyTorch應運而生。PyTorch 繼承了 Troch 的靈活特性,又使用廣為流行的 Python 作為開發語言,所以一經推出就廣受歡迎。
目錄:
入門系列教程
入門執行個體
映像、視覺、CNN相關實現
對抗產生網路、產生模型、GAN相關實現
機器翻譯、問答系統、NLP相關實現
先進視覺推理系統
深度強化學習相關實現
通用神經網路進階應用程式
1
入門系列教程
1.PyTorch Tutorials
https://github.com/MorvanZhou/PyTorch-Tutorial.git
著名的“莫煩”PyTorch系列教程的源碼。
2.Deep Learning with PyTorch: a 60-minute blitz
http://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html
PyTorch官網推薦的由網友提供的60分鐘教程,本系列教程的重點在於介紹PyTorch的基本原理,包括自動求導,神經網路,以及誤差最佳化API。
3.Simple examples to introduce PyTorch
https://github.com/jcjohnson/pytorch-examples.git
由網友提供的PyTorch教程,通過一些執行個體的方式,講解PyTorch的基本原理。內容涉及Numpy、自動求導、參數最佳化、權重共用等。
2
入門執行個體
1.Ten minutes pyTorch Tutorial
https://github.com/SherlockLiao/pytorch-beginner.git
知乎上“十分鐘學習PyTorch“系列教程的源碼。
2.Official PyTorch Examples
https://github.com/pytorch/examples
官方提供的執行個體源碼,包括以下內容:
MNIST Convnets
Word level Language Modeling using LSTM RNNs
Training Imagenet Classifiers with Residual Networks
Generative Adversarial Networks (DCGAN)
Variational Auto-Encoders
Superresolution using an efficient sub-pixel convolutional neural network
Hogwild training of shared ConvNets across multiple processes on MNIST
Training a CartPole to balance in OpenAI Gym with actor-critic
Natural Language Inference (SNLI) with GloVe vectors, LSTMs, and torchtext
Time sequence prediction - create an LSTM to learn Sine waves
3.PyTorch Tutorial for Deep Learning Researchers
https://github.com/yunjey/pytorch-tutorial.git
據說是提供給深度學習科研者們的PyTorch教程←_←。教程中的每個執行個體的代碼都控制在30行左右,簡單易懂,內容如下:
PyTorch Basics
Linear Regression
Logistic Regression
Feedforward Neural Network
Convolutional Neural Network
Deep Residual Network
Recurrent Neural Network
Bidirectional Recurrent Neural Network
Language Model (RNN-LM)
Generative Adversarial Network
Image Captioning (CNN-RNN)
Deep Convolutional GAN (DCGAN)
Variational Auto-Encoder
Neural Style Transfer
TensorBoard in PyTorch
4PyTorch-playground
https://github.com/aaron-xichen/pytorch-playground.git
PyTorch初學者的Playground,在這裡針對一下常用的資料集,已經寫好了一些模型,所以大家可以直接拿過來玩玩看,目前支援以下資料集的模型。
mnist, svhn
cifar10, cifar100
stl10
alexnet
vgg16, vgg16_bn, vgg19, vgg19_bn
resnet18, resnet34, resnet50, resnet101, resnet152
squeezenet_v0, squeezenet_v1
inception_v3
3
映像、視覺、CNN相關實現
1.PyTorch-FCN
https://github.com/wkentaro/pytorch-fcn.git
FCN(Fully Convolutional Networks implemented) 的PyTorch實現。
2.Attention Transfer
https://github.com/szagoruyko/attention-transfer.git
論文 "Paying More Attention to Attention: Improving the Performance of Convolutional Neural Networks via Attention Transfer" 的PyTorch實現。
3.Wide ResNet model in PyTorch
https://github.com/szagoruyko/functional-zoo.git
一個PyTorch實現的 ImageNet Classification 。
4.CRNN for image-based sequence recognition
https://github.com/bgshih/crnn.git
這個是 Convolutional Recurrent Neural Network (CRNN) 的 PyTorch 實現。CRNN 由一些CNN,RNN和CTC組成,常用於基於映像的序列識別任務,例如情境文本識別和OCR。
5.Scaling the Scattering Transform: Deep Hybrid Networks
https://github.com/edouardoyallon/pyscatwave.git
使用了“scattering network”的CNN實現,特別的構架提升了網路的效果。
6.Conditional Similarity Networks (CSNs)
https://github.com/andreasveit/conditional-similarity-networks.git
《Conditional Similarity Networks》的PyTorch實現。
7.Multi-style Generative Network for Real-time Transfer
https://github.com/zhanghang1989/PyTorch-Style-Transfer.git
MSG-Net 以及 Neural Style 的 PyTorch 實現。
8.Big batch training
https://github.com/eladhoffer/bigBatch.git
《Train longer, generalize better: closing the generalization gap in large batch training of neural networks》的 PyTorch 實現。
9.CortexNet
https://github.com/e-lab/pytorch-CortexNet.git
一個使用視頻訓練的魯棒預測深度神經網路。
10.Neural Message Passing for Quantum Chemistry
https://github.com/priba/nmp_qc.git
論文《Neural Message Passing for Quantum Chemistry》的PyTorch實現,好像是講電腦視覺下的神經資訊傳遞。
4
對抗產生網路、產生模型、GAN相關實現
1.Generative Adversarial Networks (GANs) in PyTorch
https://github.com/devnag/pytorch-generative-adversarial-networks.git
一個非常簡單的由PyTorch實現的對抗產生網路
2.DCGAN & WGAN with Pytorch
https://github.com/chenyuntc/pytorch-GAN.git
由中國網友實現的DCGAN和WGAN,代碼很簡潔。
3.Official Code for WGAN
https://github.com/martinarjovsky/WassersteinGAN.git
WGAN的官方PyTorch實現。
4.DiscoGAN in PyTorch
https://github.com/carpedm20/DiscoGAN-pytorch.git
《Learning to Discover Cross-Domain Relations with Generative Adversarial Networks》的 PyTorch 實現。
5.Adversarial Generator-Encoder Network
https://github.com/DmitryUlyanov/AGE.git
《Adversarial Generator-Encoder Networks》的 PyTorch 實現。
6.CycleGAN and pix2pix in PyTorch
https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix.git
圖到圖的翻譯,著名的 CycleGAN 以及 pix2pix 的PyTorch 實現。
7.Weight Normalized GAN
https://github.com/stormraiser/GAN-weight-norm.git
《On the Effects of Batch and Weight Normalization in Generative Adversarial Networks》的 PyTorch 實現。
5
機器翻譯、問答系統、NLP相關實現
1.DeepLearningForNLPInPytorch
https://github.com/rguthrie3/DeepLearningForNLPInPytorch.git
一套以 NLP 為主題的 PyTorch 基礎教程。本教程使用Ipython Notebook編寫,看起來很直觀,方便學習。
2.Practial Pytorch with Topic RNN & NLP
https://github.com/spro/practical-pytorch
以 RNN for NLP 為出發點的 PyTorch 基礎教程,分為“RNNs for NLP”和“RNNs for timeseries data”兩個部分。
3.PyOpenNMT: Open-Source Neural Machine Translation
https://github.com/OpenNMT/OpenNMT-py.git
一套由PyTorch實現的機器翻譯系統。
4.Deal or No Deal? End-to-End Learning for Negotiation Dialogues
https://github.com/facebookresearch/end-to-end-negotiator.git
Facebook AI Research 論文《Deal or No Deal? End-to-End Learning for Negotiation Dialogues》的 PyTorch 實現。
5.Attention is all you need: A Pytorch Implementation
https://github.com/jadore801120/attention-is-all-you-need-pytorch.git
Google Research 著名論文《Attention is all you need》的PyTorch實現。
6.Improved Visual Semantic Embeddings
https://github.com/fartashf/vsepp.git
一種從映像中檢索文字的方法,來自論文:《VSE++: Improved Visual-Semantic Embeddings》。
7.Reading Wikipedia to Answer Open-Domain Questions
https://github.com/facebookresearch/DrQA.git
一個開放領域問答系統DrQA的PyTorch實現。