108 Star 884 Fork 1.5K

MindSpore/models

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Contents

Algorithm Introduction

The Davincit chips are used in many service scenarios for image and video classification, object detection, and segmentation. In these scenarios, there are various requirements for real-time performance or precision. The current model is optimized based on a backbone network. Therefore, it is important to find a backbone model that runs efficiently and with high accuracy on a D-chip.

Algorithm Description

The current NAS method has two approaches:

a) Search for the Cell Internal Structure(Micro-level Structure). However, the stacking mode of cells is fixed. Such work has DARTS, PNAS, AmoebaNet.

b) Search for how to stack these Cell's Macro-level structure of channel. The structure of the cell is fixed such cell has Residual Bottleneck, ResNext Block, MobileNet Block. Such work has EffecientNet, RegNet, SM-NAS.

It can be seen that a neural network Micro-level Structure and Macro-level structure are very important for their performance. We expect to use the NAS method to obtain efficient cell designs on D chips and to use these efficient cells to construct an efficient entire network. Therefore, we adopt a two-stage search strategy:

Micro-level Search: Search for efficient cell designs on a D-chip.

Macro-Level Search: Use the efficient cell design obtained in the previous phase to construct an efficient entire network.

Configuring

For details, see the configuration file src/dnet_nas.yml in the sample code.

pipeline: [block_nas, net_nas]

block_nas:
    pipe_step:
        type: SearchPipeStep

    search_algorithm:
        type: DblockNas
        codec: DblockNasCodec
        range:
            max_sample: 100
            min_sample: 10

    search_space:
        hyperparameters:
            -   key: network.backbone.op_num
                type: CATEGORY
                range: [2, 3]
            -   key: network.backbone.skip_num
                type: CATEGORY
                range: [0, 1,]
            -   key: network.backbone.base_channel
                type: CATEGORY
                range:  [16, 32, 64]
                #range:  [16, 32, 48, 56, 64]
            -   key: network.backbone.doublechannel
                type: CATEGORY
                range: [3, 4]
            -   key: network.backbone.downsample
                type: CATEGORY
                range: [3, 4]
    model:
        model_desc:
            modules: ['backbone']
            backbone:
                type: DNet
                n_class: 1000

net_nas:
    search_algorithm:
        type: DnetNas
        codec: DnetNasCodec
        policy:
            num_mutate: 10
            random_ratio: 0.5
        range:
            max_sample: 100
            min_sample: 10

    search_space:
        hyperparameters:
            -   key: network.backbone.code_length
                type: INT
                range: [12,50]
            -   key: network.backbone.base_channel
                type: CATEGORY
                range:  [32, 64, 128]
            -   key: network.backbone.final_channel
                type: CATEGORY
                range:  [512, 1024, 2048]
            -   key: network.backbone.downsample
                type: CATEGORY
                range: [2, 3]
    model:
        models_folder: "{local_base_path}/output/block_nas/"
        model_desc:
            modules: ['backbone']
            backbone:
                type: DNet
                n_class: 1000

Dataset

The benchmark datasets can be downloaded as follows:

ImageNet2012.

After downloaded the correspond dataset to the target place, You can configure and use the dataset separately for train and test.

Dataset configuration parameters in src/dnet_nas.yml:

        type: Imagenet
        common:
            data_path: "/cache/datasets/ILSVRC/Data/CLS-LOC"
            batch_size: 64
            n_class: 1000

Requirements

Hardware (Ascend)

Prepare hardware environment with Ascend.

Framework

MindSpore

For more information, please check the resources below

MindSpore Tutorials MindSpore Python API

Script Description

Scripts and Sample Code

dnet_nas
├── eval.py # inference entry
├── train.py # pre-training entry
├── README.md # Readme
├── scripts
│   ├── run_standalone.sh # shell script for standalone train on ascend
│   ├── run_distributed.sh # shell script for distributed train on ascend
└── src
    └── dnet_nas.yml # options/hyper-parameters of dnet_nas

Script Parameter

For details about hyperparameters, see src/dnet_nas.yml.

Training Process

For training

  • Standalone Ascend Training:
sh scripts/run_standalone.sh
  • Distributed Ascend Training:
sh scripts/run_distributed.sh  [RANK_TABLE_FILE]

For distributed training, a hccl configuration file with JSON format needs to be created in advance.

Please follow the instructions in the link below:

https://gitee.com/mindspore/models/tree/master/utils/hccl_tools. $RANK_TABLE_FILE is needed when you are running a distribute task on ascend.

Or one can run following script for all tasks.

python3 train.py

Evaluation

Evaluation Process

Inference example:

Modify src/eval.yml:

models_folder: [CHECKPOINT_PATH]
python3 eval.py

Evaluation Result

The result are evaluated by the value of accuracy, flops, params and inference time.

For details about inference performance, see noah-vega modelzoo.

ModelZoo Homepage

Please check the official homepage.

FAQ

  • this network doesn't support PYNATIVE mode.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mindspore/models.git
git@gitee.com:mindspore/models.git
mindspore
models
models
master

搜索帮助