GithubHelp home page GithubHelp logo

techxzen / pytorch-residual-networks Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 0.0 314 KB

A PyTorch re-implementation of "Deep Residual Learning for Image Recognition" on Cifar-10 dataset.

License: MIT License

Python 99.45% Shell 0.55%

pytorch-residual-networks's Introduction

pytorch-residual-networks

This repository is a PyTorch re-implementation of Kaiming He's "Deep Residual Learning for Image Recognition". As the Section 4.2 CIFAR-10 and Analysis, we present experiments on Cifar-10 dataset.

ResNet on Cifar-10

1. Dataset

Dataset: https://www.cs.toronto.edu/~kriz/cifar.html

Data layout: (binaries)

Each image's size is 32x32. A 3073 byte data is used for a single image. The first byte is the label of the first image, which is a number in the range 0-9. The next 3072 bytes are the values of the pixels of the image. The first 1024 bytes are the red channel values, the next 1024 the green, and the final 1024 the blue. The values are stored in row-major order.

2. Data Augmentation

  1. RandomHorizontalFlip, p = 0.5
  2. RandomCrop, crop to 32x32 with edge-padding=4
  3. per-pixel mean substracted, (125, 123, 114) for RGB channel.

3. ResNet Arch

The ResNet architecture has 6n+2 stacked weighted layers.

  1. The first layer is conv 3x3.
  2. Then a stack of 6n layers with conv3x3 on [ feature map of size {32, 16, 8} respectively, number of filters are {16, 32, 64} respectively ], with 2n layers for each feature map size.
  3. The feature map subsampling is performed with conv3x3 with stride of 2.
  4. End with a global average pooling, a 10-way fully-connected layer, and softmax.

We vary n = 3, 5, 7, 9 for ResNet-20, ResNet-32, ResNet-44, and ResNet-56.

4. Hyper-parameter when training

  1. SGD, batch_size=100
  2. initial lr=0.1, divide by 10 at 32k and 48k iterations, terminate at 64k iterations
  3. weight decay=0.0001, momentum=0.9
  4. weight initialization
  5. BatchNormalization, without Dropout

5. Loss curve

PlainNet, without Residual block

training error and test error

1567007418500

ResNet

training error and test error

1567007442247

6. Error rate (%)

#Layer PlainNet ResNet
20 10.08 8.74
32 11.15 8.30
44 14.12 7.16
56 15.39 7.41

For PlainNet, we can observe the degradation problem: with the network depth increasing, accuracy gets saturated, and then degrades rapidly. ResNet has no more parameters, but achieves high accuracy. And increase ResNet's depth to 44 layers, the error rate is still declining.

7. Use the code

# For ResNet-56, n=9
python run.py 9 train
# Show training curve, Pytorch+Tensorboardx
tensorboard --logdir=./logs

pytorch-residual-networks's People

Contributors

techxzen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.