Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
zjuter0126 727fd22331 | 2 years ago | |
---|---|---|
ascend310_infer | 2 years ago | |
infer | 2 years ago | |
modelarts | 2 years ago | |
scripts | 2 years ago | |
src | 2 years ago | |
README.md | 2 years ago | |
README_CN.md | 2 years ago | |
docker_start.sh | 2 years ago | |
eval.py | 2 years ago | |
export.py | 2 years ago | |
postprocess.py | 2 years ago | |
preprocess.py | 2 years ago | |
train.py | 2 years ago |
Inception_ResNet_v2 is a convolutional neural network architecture that builds on previous iterations of the Inception family by simplifying the architecture and using more inception modules than Inception-v3. This idea was proposed in the paper Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning, published in 2016.
Paper Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi. Computer Vision and Pattern Recognition[J]. 2016.
The overall network architecture of Inception_ResNet_v2 is show below:
The dataset used is ImageNet.
The mixed precision training method accelerates the deep learning neural network training process by using both the single-precision and half-precision data formats, and maintains the network precision achieved by the single-precision training at the same time. Mixed precision training can accelerate the computation process, reduce memory usage, and enable a larger model or batch size to be trained on specific hardware.
For FP16 operators, if the input data type is FP32, the backend of MindSpore will automatically handle it with reduced precision. Users could check the reduced-precision operators by enabling INFO log and then searching ‘reduce precision’.
.
└─inception_resnet_v2
├─README.md
├─scripts
├─run_standalone_train_ascend.sh # launch standalone training with ascend platform(1p)
├─run_distribute_train_ascend.sh # launch distributed training with ascend platform(8p)
└─run_eval_ascend.sh # launch evaluating with ascend platform
├─src
├─config.py # parameter configuration
├─dataset.py # data preprocessing
├─inception_resnet_v2.py.py # network definition
└─callback.py # eval callback function
├─eval.py # eval net
├─export.py # export checkpoint, surpport .onnx, .air, .mindir convert
└─train.py # train net
Major parameters in train.py and config.py are:
'is_save_on_master' # save checkpoint only on master device
'batch_size' # input batchsize
'epoch_size' # total epoch numbers
'num_classes' # dataset class numbers
'work_nums' # number of workers to read data
'loss_scale' # loss scale
'smooth_factor' # label smoothing factor
'weight_decay' # weight decay
'momentum' # momentum
'optim' # optimizer, Supports [momentum, rmsprop]
'amp_level' # precision training, Supports [O0, O2, O3]
'decay' # decay used in optimize function
'epsilon' # epsilon used in iptimize function
'keep_checkpoint_max' # max numbers to keep checkpoints
'save_checkpoint_epochs' # save checkpoints per n epoch
'lr_init' # init leaning rate
'lr_end' # end of learning rate
'lr_max' # max bound of learning rate
'warmup_epochs' # warmup epoch numbers
'start_epoch' # number of start epoch range[1, epoch_size]
You can start training using python or shell scripts. The usage of shell scripts as follows:
# distribute training example(8p)
bash scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_PATH DATA_DIR
# standalone training
bash scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR
Notes:
RANK_TABLE_FILE can refer to Link , and the device_ip can be got as Link. For large models like InceptionV4, it's better to export an external environment variableexport HCCL_CONNECT_TIMEOUT=600
to extend hccl connection checking time from the default 120 seconds to 600 seconds. Otherwise, the connection could be timeout since compiling time increases with the growth of model size.This is processor cores binding operation regarding the
device_num
and total processor numbers. If you are not expect to do it, remove the operationstaskset
inscripts/run_distribute_train.sh
# training example
shell:
Ascend:
# distribute training example(8p)
bash scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_DIR
# standalone training
bash scripts/run_standalone_train_ascend.sh
# training example
shell:
GPU:
# distribute training example(8p)
bash scripts/run_distribute_train_gpu.sh DEVICE_NUM DEVICE_ID DATA_DIR
# standalone training
bash scripts/run_standalone_train_gpu.sh DEVICE_ID DATA_DIR
Training result will be stored in the example path. Checkpoints will be stored at ckpt_path
by default, and training log will be redirected to ./log.txt
like following.
epoch: 1 step: 1251, loss is 5.4833196
Epoch time: 520274.060, per step time: 415.887
epoch: 2 step: 1251, loss is 4.093194
Epoch time: 288520.628, per step time: 230.632
epoch: 3 step: 1251, loss is 3.6242008
Epoch time: 288507.506, per step time: 230.622
You can start training using python or shell scripts. The usage of shell scripts as follows:
bash scripts/run_eval_ascend.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
bash scripts/run_eval_gpu.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
checkpoint can be produced in training process.
Evaluation result will be stored in the example path, you can find result like the following in eval.log
.
Ascend:
metric: {'Loss': 1.0413, 'Top1-Acc':0.79955, 'Top5-Acc':0.9439}
GPU:
metric: {'Loss': 0.8618191335636836, 'Top1-Acc': 0.8026642628205128, 'Top5-Acc': 0.9520833333333333}
Parameters | Ascend | GPU |
---|---|---|
Model Version | Inception ResNet v2 | Inception ResNet v2 |
Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G | Tesla V100 SXM2;CPU:2.3GHz,32scores;memory:512G |
uploaded Date | 11/04/2020 | 09/23/2021 |
MindSpore Version | 1.2.0 | 1.3.0 |
Dataset | 1200k images | 1200k images |
Batch_size | 128 | 128 |
Training Parameters | src/config.py | src/config.py |
Optimizer | RMSProp | Momentum |
Loss Function | SoftmaxCrossEntropyWithLogits | CrossEntropySmooth |
Outputs | probability | probability |
Total time | 24h(8p) | 38h(4p) |
performance | 1p: 556 img/s / 8p: 4430 img/s | 4p: 868 ims/s |
Parameters | Ascend | GPU |
---|---|---|
Model Version | Inception ResNet v2 | Inception ResNet v2 |
Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G | Tesla V100 SXM2, cpu:2.3GHz 32scores, memory: 512G |
Uploaded Date | 11/04/2020 | 09/23/2021 |
MindSpore Version | 1.2.0 | 1.3.0 |
Dataset | 50k images | 50k images |
Batch_size | 128 | 128 |
Outputs | probability | probability |
Accuracy | ACC1[79.96%] ACC5[94.40%] | ACC1[80.46%] ACC5[95.24%] |
In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
Please check the official homepage.
Inception_ResNet_v2是Google的深度学习卷积架构系列的一个版本。Inception_ResNet_v2主要通过修改以前的Inception架构来减少计算资源的消耗。该方法在2016年出版的Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning一文中提出的。
Python C++ Shell Markdown Text other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》