|
|
|
@ -32,7 +32,6 @@ The overall network architecture of ResNeXt is show below:
|
|
|
|
|
|
|
|
|
|
[Link](https://arxiv.org/abs/1611.05431)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# [Dataset](#contents)
|
|
|
|
|
|
|
|
|
|
Dataset used: [imagenet](http://www.image-net.org/)
|
|
|
|
@ -40,10 +39,9 @@ Dataset used: [imagenet](http://www.image-net.org/)
|
|
|
|
|
- Dataset size: ~125G, 1.2W colorful images in 1000 classes
|
|
|
|
|
- Train: 120G, 1.2W images
|
|
|
|
|
- Test: 5G, 50000 images
|
|
|
|
|
- Data format: RGB images.
|
|
|
|
|
- Data format: RGB images
|
|
|
|
|
- Note: Data will be processed in src/dataset.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# [Features](#contents)
|
|
|
|
|
|
|
|
|
|
## [Mixed Precision](#contents)
|
|
|
|
@ -107,7 +105,7 @@ For FP16 operators, if the input data type is FP32, the backend of MindSpore wil
|
|
|
|
|
|
|
|
|
|
Parameters for both training and evaluating can be set in config.py.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```config
|
|
|
|
|
"image_height": '224,224' # image size
|
|
|
|
|
"num_classes": 1000, # dataset class number
|
|
|
|
|
"per_batch_size": 128, # batch size of input tensor
|
|
|
|
@ -118,7 +116,6 @@ Parameters for both training and evaluating can be set in config.py.
|
|
|
|
|
"eta_min": 0, # eta_min in cosine_annealing scheduler
|
|
|
|
|
"T_max": 150, # T-max in cosine_annealing scheduler
|
|
|
|
|
"max_epoch": 150, # max epoch num to train the model
|
|
|
|
|
"backbone": 'resnext50', # backbone metwork
|
|
|
|
|
"warmup_epochs" : 1, # warmup epoch
|
|
|
|
|
"weight_decay": 0.0001, # weight decay
|
|
|
|
|
"momentum": 0.9, # momentum
|
|
|
|
@ -135,17 +132,17 @@ Parameters for both training and evaluating can be set in config.py.
|
|
|
|
|
|
|
|
|
|
## [Training Process](#contents)
|
|
|
|
|
|
|
|
|
|
#### Usage
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
|
|
You can start training by python script:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```script
|
|
|
|
|
python train.py --data_dir ~/imagenet/train/ --platform Ascend --is_distributed 0
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
or shell stript:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```script
|
|
|
|
|
Ascend:
|
|
|
|
|
# distribute training example(8p)
|
|
|
|
|
sh run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
|
|
|
|
@ -180,16 +177,17 @@ You can find checkpoint file together with result in log.
|
|
|
|
|
|
|
|
|
|
You can start training by python script:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```script
|
|
|
|
|
python eval.py --data_dir ~/imagenet/val/ --platform Ascend --pretrained resnext.ckpt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
or shell stript:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```script
|
|
|
|
|
# Evaluation
|
|
|
|
|
sh run_eval.sh DEVICE_ID DATA_PATH PRETRAINED_CKPT_PATH PLATFORM
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
PLATFORM is Ascend or GPU, default is Ascend.
|
|
|
|
|
|
|
|
|
|
#### Launch
|
|
|
|
@ -203,7 +201,7 @@ sh scripts/run_eval.sh 0 /opt/npu/datasets/classification/val /resnext50_100.ckp
|
|
|
|
|
|
|
|
|
|
Evaluation result will be stored in the scripts path. Under this, you can find result like the followings in log.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```log
|
|
|
|
|
acc=78.16%(TOP1)
|
|
|
|
|
acc=93.88%(TOP5)
|
|
|
|
|
```
|
|
|
|
@ -212,7 +210,7 @@ acc=93.88%(TOP5)
|
|
|
|
|
|
|
|
|
|
Change the export mode and export file in `src/config.py`, and run `export.py`.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
```script
|
|
|
|
|
python export.py --platform PLATFORM --pretrained CKPT_PATH
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -248,7 +246,6 @@ python export.py --platform PLATFORM --pretrained CKPT_PATH
|
|
|
|
|
| outputs | probability | probability | probability |
|
|
|
|
|
| Accuracy | acc=78.16%(TOP1) | acc=78.05%(TOP1) | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# [Description of Random Situation](#contents)
|
|
|
|
|
|
|
|
|
|
In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
|
|
|
|
|