You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mindspore/model_zoo/official/cv/alexnet
wukesong e7b8d5eeac
modify readme
5 years ago
..
scripts add script shell 5 years ago
src modify epoch 5 years ago
README.md modify readme 5 years ago
eval.py modify dataste_sink_mode 5 years ago
requirements.txt add script shell 5 years ago
train.py modify dataste_sink_mode 5 years ago

README.md

Contents

AlexNet Description

AlexNet was proposed in 2012, one of the most influential neural networks. It got big success in ImageNet Dataset recognition than other models.

Paper: Krizhevsky A, Sutskever I, Hinton G E. ImageNet Classification with Deep ConvolutionalNeural Networks. Advances In Neural Information Processing Systems. 2012.

Model Architecture

AlexNet composition consists of 5 convolutional layers and 3 fully connected layers. Multiple convolutional kernels can extract interesting features in images and get more accurate classification.

Dataset

Dataset used: CIFAR-10

  • Dataset size175M60,000 32*32 colorful images in 10 classes
    • Train146M50,000 images
    • Test29.3M10,000 images
  • Data formatbinary files
    • NoteData will be processed in dataset.py
  • Download the dataset, the directory structure is as follows:
├─cifar-10-batches-bin
│
└─cifar-10-verify-bin

Environment Requirements

Quick Start

After installing MindSpore via the official website, you can start training and evaluation as follows:

# enter script dir, train AlexNet
sh run_standalone_train_ascend.sh [DATA_PATH] [CKPT_SAVE_PATH]  
# enter script dir, evaluate AlexNet
sh run_standalone_eval_ascend.sh [DATA_PATH] [CKPT_NAME]

Script Description

Script and Sample Code

├── cv
    ├── alexnet        
        ├── README.md                    // descriptions about alexnet
        ├── requirements.txt             // package needed
        ├── scripts 
        │   ├──run_standalone_train_gpu.sh             // train in gpu 
        │   ├──run_standalone_train_ascend.sh          // train in ascend 
        │   ├──run_standalone_eval_gpu.sh             //  evaluate in gpu 
        │   ├──run_standalone_eval_ascend.sh          //  evaluate in ascend 
        ├── src 
        │   ├──dataset.py             // creating dataset
        │   ├──alexnet.py              // alexnet architecture
        │   ├──config.py            // parameter configuration 
        ├── train.py               // training script 
        ├── eval.py               //  evaluation script  

Script Parameters

Major parameters in train.py and config.py as follows:

--data_path: The absolute full path to the train and evaluation datasets. 
--epoch_size: Total training epochs. 
--batch_size: Training batch size.  
--image_height: Image height used as input to the model.
--image_width: Image width used as input the model. 
--device_target: Device where the code will be implemented. Optional values are "Ascend", "GPU". 
--checkpoint_path: The absolute full path to the checkpoint file saved after training.
--data_path: Path where the dataset is saved    

Training Process

Training

python train.py --data_path cifar-10-batches-bin --ckpt_path ckpt > log.txt 2>&1 &  
# or enter script dir, and run the script
sh run_standalone_train_ascend.sh cifar-10-batches-bin ckpt  

After training, the loss value will be achieved as follows:

# grep "loss is " train.log
epoch: 1 step: 1, loss is 2.2791853
...
epoch: 1 step: 1536, loss is 1.9366643
epoch: 1 step: 1537, loss is 1.6983616
epoch: 1 step: 1538, loss is 1.0221305
...

The model checkpoint will be saved in the current directory.

Evaluation Process

Evaluation

Before running the command below, please check the checkpoint path used for evaluation.

python eval.py --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-1_1562.ckpt > log.txt 2>&1 &  
or enter script dir, and run the script
sh run_standalone_eval_ascend.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-1_1562.ckpt

You can view the results through the file "log.txt". The accuracy of the test dataset will be as follows:

# grep "Accuracy: " log.txt
'Accuracy': 0.8832 

Model Description

Performance

Evaluation Performance

Parameters AlexNet
Resource Ascend 910 CPU 2.60GHz56coresMemory314G
uploaded Date 06/09/2020 (month/day/year)
MindSpore Version 0.5.0-beta
Dataset CIFAR-10
Training Parameters epoch=30, steps=1562, batch_size = 32, lr=0.002
Optimizer Momentum
Loss Function Softmax Cross Entropy
outputs probability
Loss 0.0016
Speed 21 ms/step
Total time 17 mins
Checkpoint for Fine tuning 445M (.ckpt file)
Scripts https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet

Description of Random Situation

In dataset.py, we set the seed inside create_dataset function.

ModelZoo Homepage

Please check the official homepage.