tree: 7a34f8c9a621d1f9ff0a1236f6eeadb8e3b8d3e8 [path history] [tgz]
  2. CMakeLists.txt
  5. ilsvrc12.h

Train AlexNet over ImageNet

Convolution neural network (CNN) is a type of feed-forward neural network widely used for image and video classification. In this example, we will use a deep CNN model to do image classification against the ImageNet dataset.


Compile SINGA

Please compile SINGA with CUDA, CUDNN and OpenCV. You can manually turn on the options in CMakeLists.txt or run ccmake .. in build/ folder.

We have tested CUDNN V4 and V5 (V5 requires CUDA 7.5)

Data download

Data preprocessing

  • Assuming you have downloaded the data and the list. Now we should transform the data into binary files. You can run:


    The script will generate a test file(test.bin), a mean file(mean.bin) and several training files(trainX.bin) in the specified output folder.

  • You can also change the parameters in

    • -trainlist <file>: the file of training list;
    • -trainfolder <folder>: the folder of training images;
    • -testlist <file>: the file of test list;
    • -testfolder <floder>: the folder of test images;
    • -outdata <folder>: the folder to save output files, including mean, training and test files. The script will generate these files in the specified folder;
    • -filesize <int>: number of training images that stores in each binary file.


  • After preparing data, you can run the following command to train the Alexnet model.

  • You may change the parameters in

    • -epoch <int>: number of epoch to be trained, default is 90;
    • -lr <float>: base learning rate, the learning rate will decrease each 20 epochs, more specifically, lr = lr * exp(0.1 * (epoch / 20));
    • -batchsize <int>: batchsize, it should be changed regarding to your memory;
    • -filesize <int>: number of training images that stores in each binary file, it is the same as the filesize in data preprocessing;
    • -ntrain <int>: number of training images;
    • -ntest <int>: number of test images;
    • -data <folder>: the folder which stores the binary files, it is exactly the output folder in data preprocessing step;
    • -pfreq <int>: the frequency(in batch) of printing current model status(loss and accuracy);
    • -nthreads <int>: the number of threads to load data which feed to the model.