• Stars
    star
    346
  • Rank 122,430 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ConvNet training using pytorch

Convolutional networks using PyTorch

This is a complete training example for Deep Convolutional Networks on various datasets (ImageNet, Cifar10, Cifar100, MNIST).

Available models include:

'alexnet', 'amoebanet', 'darts', 'densenet', 'googlenet', 'inception_resnet_v2', 'inception_v2', 'mnist', 'mobilenet', 'mobilenet_v2', 'nasnet', 'resnet', 'resnet_se', 'resnet_zi', 'resnet_zi_se', 'resnext', 'resnext_se'

It is based off imagenet example in pytorch with helpful additions such as:

  • Training on several datasets other than imagenet
  • Complete logging of trained experiment
  • Graph visualization of the training/validation loss and accuracy
  • Definition of preprocessing and optimization regime for each model
  • Distributed training

To clone:

git clone --recursive https://github.com/eladhoffer/convNet.pytorch

example for efficient multi-gpu training of resnet50 (4 gpus, label-smoothing):

python -m torch.distributed.launch --nproc_per_node=4  main.py --model resnet --model-config "{'depth': 50}" --eval-batch-size 512 --save resnet50_ls --label-smoothing 0.1

This code can be used to implement several recent papers:

Dependencies

Data

  • Configure your dataset path with datasets-dir argument
  • To get the ILSVRC data, you should register on their site for access: http://www.image-net.org/

Model configuration

Network model is defined by writing a .py file in models folder, and selecting it using the model flag. Model function must be registered in models/__init__.py The model function must return a trainable network. It can also specify additional training options such optimization regime (either a dictionary or a function), and input transform modifications.

e.g for a model definition:

class Model(nn.Module):

    def __init__(self, num_classes=1000):
        super(Model, self).__init__()
        self.model = nn.Sequential(...)

        self.regime = [
            {'epoch': 0, 'optimizer': 'SGD', 'lr': 1e-2,
                'weight_decay': 5e-4, 'momentum': 0.9},
            {'epoch': 15, 'lr': 1e-3, 'weight_decay': 0}
        ]

        self.data_regime = [
            {'epoch': 0, 'input_size': 128, 'batch_size': 256},
            {'epoch': 15, 'input_size': 224, 'batch_size': 64}
        ]
    def forward(self, inputs):
        return self.model(inputs)
        
 def model(**kwargs):
        return Model()

Citation

If you use the code in your paper, consider citing one of the implemented works.

@inproceedings{hoffer2018fix,
  title={Fix your classifier: the marginal value of training the last weight layer},
  author={Elad Hoffer and Itay Hubara and Daniel Soudry},
  booktitle={International Conference on Learning Representations},
  year={2018},
  url={https://openreview.net/forum?id=S1Dh8Tg0-},
}
@inproceedings{hoffer2018norm,
  title={Norm matters: efficient and accurate normalization schemes in deep networks},
  author={Hoffer, Elad and Banner, Ron and Golan, Itay and Soudry, Daniel},
  booktitle={Advances in Neural Information Processing Systems},
  year={2018}
}
@inproceedings{banner2018scalable,
  title={Scalable Methods for 8-bit Training of Neural Networks},
  author={Banner, Ron and Hubara, Itay and Hoffer, Elad and Soudry, Daniel},
  booktitle={Advances in Neural Information Processing Systems},
  year={2018}
}
@inproceedings{Hoffer_2020_CVPR,
  author = {Hoffer, Elad and Ben-Nun, Tal and Hubara, Itay and Giladi, Niv and Hoefler, Torsten and Soudry, Daniel},
  title = {Augment Your Batch: Improving Generalization Through Instance Repetition},
  booktitle = {The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  month = {June},
  year = {2020}
}
@article{hoffer2019mix,
  title={Mix \& Match: training convnets with mixed image sizes for improved accuracy, speed and scale resiliency},
  author={Hoffer, Elad and Weinstein, Berry and Hubara, Itay and Ben-Nun, Tal and Hoefler, Torsten and Soudry, Daniel},
  journal={arXiv preprint arXiv:1908.08986},
  year={2019}
}

More Repositories

1

seq2seq.pytorch

Sequence-to-Sequence learning using PyTorch
Python
520
star
2

quantized.pytorch

Python
212
star
3

TripletNet

Deep metric learning using Triplet network
Lua
189
star
4

bigBatch

Code used to generate the results appearing in "Train longer, generalize better: closing the generalization gap in large batch training of neural networks"
Python
148
star
5

captionGen

Generate captions for an image using PyTorch
Jupyter Notebook
128
star
6

ImageNet-Training

ImageNet training using torch
Lua
102
star
7

utils.pytorch

Utilities for Pytorch
Python
90
star
8

DeepDream.torch

Torch version for https://github.com/google/deepdream
Lua
53
star
9

fix_your_classifier

Python
34
star
10

recurrent.torch

Recurrent modules for Torch
Lua
27
star
11

lmdb.torch

LMDB for Torch
Lua
26
star
12

norm_matters

Python
23
star
13

SemiSupContrast

Semi-supervised deep learning by metric embedding
Lua
19
star
14

DeepLearningCourse

Deep learning mini-course given at Technion
Jupyter Notebook
18
star
15

convNet.torch

Convolutional network training using Torch
Lua
18
star
16

captionGeneration.torch

Generate captions for an image using convolutional and recurrent networks
Jupyter Notebook
12
star
17

eladtools

Lua
11
star
18

ConvNet-torch

Training Deep Convolutional Networks on visual classification tasks
Lua
11
star
19

GoogLeNet.torch

Trained network models for Torch
9
star
20

convNet.tf

Convolutional network training using TensorFlow
Python
8
star
21

stl10.torch

STL10 Dataset on Torch
Lua
3
star
22

DataProvider.torch

Data providers for Torch
Lua
3
star
23

eladhoffer.github.io

CSS
3
star
24

colab-notebooks

Jupyter Notebook
2
star
25

seq2seq.torch

Lua
1
star
26

DescriptorLearning

Lua
1
star