资源算法pytorch-cifar100

pytorch-cifar100

2020-02-06 | |  32 |   0 |   0

Pytorch-cifar100

practice on cifar100 using pytorch

Requirements

This is my experiment eviroument, pytorch0.4 should also be fine

  • python3.5

  • pytorch1.0

  • tensorflow1.5(optional)

  • cuda8.0

  • cudnnv5

  • tensorboardX1.6(optional)

Usage

1. enter directory

$ cd pytorch-cifar100

2. dataset

I will use cifar100 dataset from torchvision since it's more convenient, but I also kept the sample code for writing your own dataset module in dataset folder, as an example for people don't know how to write it.

3. run tensorbard(optional)

Install tensorboardX (a tensorboard wrapper for pytorch)

$ pip install tensorboardX
$ mkdir runs
Run tensorboard
$ tensorboard --logdir='runs' --port=6006 --host='localhost'

4. train the model

Train all the model on a Tesla P40(22912MB)

You need to specify the net you want to train using arg -net

$ python train.py -net vgg16

sometimes, you might want to use warmup training by set -warm to 1 or 2, to prevent network diverge during early training phase.

The supported net args are:

squeezenet
mobilenet
mobilenetv2
shufflenet
shufflenetv2
vgg11
vgg13
vgg16
vgg19
densenet121
densenet161
densenet201
googlenet
inceptionv3
inceptionv4
inceptionresnetv2
xception
resnet18
resnet34
resnet50
resnet101
resnet152
preactresnet18
preactresnet34
preactresnet50
preactresnet101
preactresnet152
resnext50
resnext101
resnext152
attention56
attention92
seresnet18
seresnet34
seresnet50
seresnet101
seresnet152
nasnet

Normally, the weights file with the best accuracy would be written to the disk with name suffix 'best'(default in checkpoint folder).

5. test the model

Test the model using test.py

$ python test.py -net vgg16 -weights path_to_vgg16_weights_file

Implementated NetWork

Training Details

I didn't use any training tricks to improve accuray, if you want to learn more about training tricks, please refer to my another repo, contains various common training tricks and their pytorch implementations.

I follow the hyperparameter settings in paper Improved Regularization of Convolutional Neural Networks with Cutout, which is init lr = 0.1 divide by 5 at 60th, 120th, 160th epochs, train for 200 epochs with batchsize 128 and weight decay 5e-4, Nesterov momentum of 0.9. You could also use the hyperparameters from paper Regularizing Neural Networks by Penalizing Confident Output Distributions and Random Erasing Data Augmentation, which is initial lr = 0.1, lr divied by 10 at 150th and 225th epochs, and training for 300 epochs with batchsize 128, this is more commonly used. You could decrese the batchsize to 64 or whatever suits you, if you dont have enough gpu memory.

You can choose whether to use TensorBoard to visualize your training procedure

Results

The result I can get from a certain model, since I use the same hyperparameters to train all the networks, some networks might not get the best result from these hyperparameters, you could try yourself by finetuning the hyperparameters to get better result.

datasetnetworkparamstop1 errtop5 errmemoryepoch(lr = 0.1)epoch(lr = 0.02)epoch(lr = 0.004)epoch(lr = 0.0008)total epoch
cifar100mobilenet3.3M34.0210.560.69GB60604040200
cifar100mobilenetv22.36M31.9209.020.84GB60604040200
cifar100squeezenet0.78M30.598.360.73GB60604040200
cifar100shufflenet1.0M29.948.350.84GB60604040200
cifar100shufflenetv21.3M30.498.490.78GB60604040200
cifar100vgg11_bn28.5M31.3611.851.98GB60604040200
cifar100vgg13_bn28.7M28.009.711.98GB60604040200
cifar100vgg16_bn34.0M27.078.842.03GB60604040200
cifar100vgg19_bn39.0M27.778.842.08GB60604040200
cifar100resnet1811.2M24.396.953.02GB60604040200
cifar100resnet3421.3M23.246.633.22GB60604040200
cifar100resnet5023.7M22.616.043.40GB60604040200
cifar100resnet10142.7M22.225.613.72GB60604040200
cifar100resnet15258.3M22.315.814.36GB60604040200
cifar100preactresnet1811.3M27.088.533.09GB60604040200
cifar100preactresnet3421.5M24.797.683.23GB60604040200
cifar100preactresnet5023.9M25.738.153.42GB60604040200
cifar100preactresnet10142.9M24.847.833.81GB60604040200
cifar100preactresnet15258.6M22.716.624.20GB60604040200
cifar100resnext5014.8M22.236.001.91GB60604040200
cifar100resnext10125.3M22.225.992.63GB60604040200
cifar100resnext15233.3M22.405.583.18GB60604040200
cifar100attention5955.7M33.7512.903.47GB60604040200
cifar100attention92102.5M36.5211.473.88GB60604040200
cifar100densenet1217.0M22.996.451.28GB60604040200
cifar100densenet16126M21.566.042.10GB60606040200
cifar100densenet20118M21.465.92.10GB60604040200
cifar100googlenet6.2M21.975.942.05GB60604040200
cifar100inceptionv322.3M22.816.392.26GB60604040200
cifar100inceptionv441.3M24.146.904.11GB60604040200
cifar100inceptionresnetv265.4M27.519.114.14GB60604040200
cifar100xception21.0M25.077.321.67GB60604040200
cifar100seresnet1811.4M23.566.683.12GB60604040200
cifar100seresnet3421.6M22.076.123.29GB60604040200
cifar100seresnet5026.5M21.425.583.70GB60604040200
cifar100seresnet10147.7M20.985.414.39GB60604040200
cifar100seresnet15266.2M20.665.195.95GB60604040200
cifar100nasnet5.2M22.715.913.69GB60604040


上一篇:Character-level-cnn-pytorch

下一篇:cifar10-tensorflow

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...