This repository contains the examples of natural image classification using pre-trained model as well as training a Inception network from scratch on CIFAR-10 dataset (93.64% accuracy on testing set). The pre-trained model on CIFAR-10 can be download from here.
Images are rescaled so that the smallest side equals 224 before fed into the model. This is not the same as the original paper which is an ensemble of 7 similar models using 144 224x224 crops per image for testing. So the performance will not be as good as the original paper.
For training from scratch on CIFAR-10
All the LRN layers are removed from the convolutional layers.
Batch normalization and ReLU activation are used in all the convolutional layers including the layers in Inception structure except the output layer.
Two auxiliary classifiers are used as mentioned in the paper, though 512 instead of 1024 hidden units are used in the two fully connected layers to reduce the computation. However, I found the results are almost the same on CIFAR-10 with and without auxiliary classifiers.
Since the 32 x 32 images are down-sampled to 1 x 1 before fed into inception_5a, this makes the multi-scale structure of inception layers less useful and harm the performance (around 80% accuracy). To make full use of the multi-scale structures, the stride of the first convolutional layer is reduced to 1 and the first two max pooling layers are removed. The the feature map (32 x 32 x channels) will have almost the same size as described in table 1 (28 x 28 x channel) in the paper before fed into inception_3a. I have also tried only reduce the stride or only remove one max pooling layer. But I found the current setting provides the best performance on the testing set.
During training, dropout with keep probability 0.4 is applied to two fully connected layers and weight decay with 5e-4 is used as well.
The network is trained through Adam optimizer. Batch size is 128. The initial learning rate is 1e-3, decays to 1e-4 after 30 epochs, and finally decays to 1e-5 after 50 epochs.
Each color channel of the input images are subtracted by the mean value computed from the training set.
Usage
ImageNet Classification
Preparation
Download the pre-trained parameters here. This is original from here.
Setup path in examples/inception_pretrained.py: PRETRINED_PATH is the path for pre-trained model. DATA_PATH is the path to put testing images.
Run
Go to examples/ and put test image in folder DATA_PATH, then run the script:
Setup path in examples/inception_cifar.py: DATA_PATH is the path to put CIFAR-10. SAVE_PATH is the path to save or load summary file and trained model.
请发表评论