All Projects → L1aoXingyu → Deep Learning Project Template

L1aoXingyu / Deep Learning Project Template

A best practice for deep learning project template architecture.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Deep Learning Project Template

Ppo Pytorch
Minimal implementation of clipped objective Proximal Policy Optimization (PPO) in PyTorch
Stars: ✭ 325 (-49.3%)
Mutual labels:  pytorch-tutorial
Daily Deeplearning
🔥机器学习/深度学习/Python/算法面试/自然语言处理教程/剑指offer/machine learning/deeplearning/Python/Algorithm interview/NLP Tutorial
Stars: ✭ 381 (-40.56%)
Mutual labels:  pytorch-tutorial
Deep Learning With Pytorch Chinese
本仓库将PyTorch官方书籍《Deep learning with PyTorch》(基本摘录版)翻译成中文版并给出可运行的相关代码。
Stars: ✭ 517 (-19.34%)
Mutual labels:  pytorch-tutorial
Benchmarking Keras Pytorch
🔥 Reproducibly benchmarking Keras and PyTorch models
Stars: ✭ 346 (-46.02%)
Mutual labels:  pytorch-tutorial
Kind Pytorch Tutorial
Kind PyTorch Tutorial for beginners
Stars: ✭ 377 (-41.19%)
Mutual labels:  pytorch-tutorial
Awesome deep learning interpretability
深度学习近年来关于神经网络模型解释性的相关高引用/顶会论文(附带代码)
Stars: ✭ 401 (-37.44%)
Mutual labels:  chainer
Gp Gan
Official Chainer implementation of GP-GAN: Towards Realistic High-Resolution Image Blending (ACMMM 2019, oral)
Stars: ✭ 317 (-50.55%)
Mutual labels:  chainer
Pytorch Project Template
A scalable template for PyTorch projects, with examples in Image Segmentation, Object classification, GANs and Reinforcement Learning.
Stars: ✭ 557 (-13.1%)
Mutual labels:  pytorch-tutorial
Deeppose
DeepPose implementation in Chainer
Stars: ✭ 377 (-41.19%)
Mutual labels:  chainer
Chainer Chemistry
Chainer Chemistry: A Library for Deep Learning in Biology and Chemistry
Stars: ✭ 462 (-27.93%)
Mutual labels:  chainer
Fast Pytorch
Pytorch Tutorial, Pytorch with Google Colab, Pytorch Implementations: CNN, RNN, DCGAN, Transfer Learning, Chatbot, Pytorch Sample Codes
Stars: ✭ 346 (-46.02%)
Mutual labels:  pytorch-tutorial
First Steps Towards Deep Learning
This is an open sourced book on deep learning.
Stars: ✭ 376 (-41.34%)
Mutual labels:  pytorch-tutorial
Capsnet
CapsNet (Capsules Net) in Geoffrey E Hinton paper "Dynamic Routing Between Capsules" - State Of the Art
Stars: ✭ 423 (-34.01%)
Mutual labels:  chainer
Pytorch Chatbot
Pytorch seq2seq chatbot
Stars: ✭ 336 (-47.58%)
Mutual labels:  pytorch-tutorial
Video Classification
Tutorial for video classification/ action recognition using 3D CNN/ CNN+RNN on UCF101
Stars: ✭ 543 (-15.29%)
Mutual labels:  pytorch-tutorial
Cross Domain Detection
Cross-Domain Weakly-Supervised Object Detection through Progressive Domain Adaptation [Inoue+, CVPR2018].
Stars: ✭ 320 (-50.08%)
Mutual labels:  chainer
Transformers Tutorials
Github repo with tutorials to fine tune transformers for diff NLP tasks
Stars: ✭ 384 (-40.09%)
Mutual labels:  pytorch-tutorial
Early Stopping Pytorch
Early stopping for PyTorch
Stars: ✭ 612 (-4.52%)
Mutual labels:  pytorch-tutorial
See
Code for the AAAI 2018 publication "SEE: Towards Semi-Supervised End-to-End Scene Text Recognition"
Stars: ✭ 545 (-14.98%)
Mutual labels:  chainer
Pytorch Tutorial
PyTorch Tutorial for Deep Learning Researchers
Stars: ✭ 22,442 (+3401.09%)
Mutual labels:  pytorch-tutorial

PyTorch Project Template

A simple and well designed structure is essential for any Deep Learning project, so after a lot practice and contributing in pytorch projects here's a pytorch project template that combines simplicity, best practice for folder structure and good OOP design. The main idea is that there's much same stuff you do every time when you start your pytorch project, so wrapping all this shared stuff will help you to change just the core idea every time you start a new pytorch project.

So, here’s a simple pytorch template that help you get into your main project faster and just focus on your core (Model Architecture, Training Flow, etc)

In order to decrease repeated stuff, we recommend to use a high-level library. You can write your own high-level library or you can just use some third-part libraries such as ignite, fastai, mmcv … etc. This can help you write compact but full-featured training loops in a few lines of code. Here we use ignite to train mnist as an example.

Requirements

  • yacs (Yet Another Configuration System)
  • PyTorch (An open source deep learning platform)
  • ignite (High-level library to help with training neural networks in PyTorch)

Table Of Contents

In a Nutshell

In a nutshell here's how to use this template, so for example assume you want to implement ResNet-18 to train mnist, so you should do the following:

  • In modeling folder create a python file named whatever you like, here we named it example_model.py . In modeling/__init__.py file, you can build a function named build_model to call your model
from .example_model import ResNet18

def build_model(cfg):
    model = ResNet18(cfg.MODEL.NUM_CLASSES)
    return model
  • In engine folder create a model trainer function and inference function. In trainer function, you need to write the logic of the training process, you can use some third-party library to decrease the repeated stuff.
# trainer
def do_train(cfg, model, train_loader, val_loader, optimizer, scheduler, loss_fn):
 """
 implement the logic of epoch:
 -loop on the number of iterations in the config and call the train step
 -add any summaries you want using the summary
 """
pass

# inference
def inference(cfg, model, val_loader):
"""
implement the logic of the train step
- run the tensorflow session
- return any metrics you need to summarize
 """
pass
  • In tools folder, you create the train.py . In this file, you need to get the instances of the following objects "Model", "DataLoader”, “Optimizer”, and config
# create instance of the model you want
model = build_model(cfg)

# create your data generator
train_loader = make_data_loader(cfg, is_train=True)
val_loader = make_data_loader(cfg, is_train=False)

# create your model optimizer
optimizer = make_optimizer(cfg, model)
  • Pass the all these objects to the function do_train , and start your training
# here you train your model
do_train(cfg, model, train_loader, val_loader, optimizer, None, F.cross_entropy)

You will find a template file and a simple example in the model and trainer folder that shows you how to try your first model simply.

In Details

├──  config
│    └── defaults.py  - here's the default config file.
│
│
├──  configs  
│    └── train_mnist_softmax.yml  - here's the specific config file for specific model or dataset.
│ 
│
├──  data  
│    └── datasets  - here's the datasets folder that is responsible for all data handling.
│    └── transforms  - here's the data preprocess folder that is responsible for all data augmentation.
│    └── build.py  		   - here's the file to make dataloader.
│    └── collate_batch.py   - here's the file that is responsible for merges a list of samples to form a mini-batch.
│
│
├──  engine
│   ├── trainer.py     - this file contains the train loops.
│   └── inference.py   - this file contains the inference process.
│
│
├── layers              - this folder contains any customed layers of your project.
│   └── conv_layer.py
│
│
├── modeling            - this folder contains any model of your project.
│   └── example_model.py
│
│
├── solver             - this folder contains optimizer of your project.
│   └── build.py
│   └── lr_scheduler.py
│   
│ 
├──  tools                - here's the train/test model of your project.
│    └── train_net.py  - here's an example of train model that is responsible for the whole pipeline.
│ 
│ 
└── utils
│    ├── logger.py
│    └── any_other_utils_you_need
│ 
│ 
└── tests					- this foler contains unit test of your project.
     ├── test_data_sampler.py

Future Work

Contributing

Any kind of enhancement or contribution is welcomed.

Acknowledgments

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].