Densely Connected Search Space for More Flexible Neural Architecture Search (CVPR2020)

Overview

DenseNAS

The code of the CVPR2020 paper Densely Connected Search Space for More Flexible Neural Architecture Search.

Neural architecture search (NAS) has dramatically advanced the development of neural network design. We revisit the search space design in most previous NAS methods and find the number of blocks and the widths of blocks are set manually. However, block counts and block widths determine the network scale (depth and width) and make a great influence on both the accuracy and the model cost (FLOPs/latency).

We propose to search block counts and block widths by designing a densely connected search space, i.e., DenseNAS. The new search space is represented as a dense super network, which is built upon our designed routing blocks. In the super network, routing blocks are densely connected and we search for the best path between them to derive the final architecture. We further propose a chained cost estimation algorithm to approximate the model cost during the search. Both the accuracy and model cost are optimized in DenseNAS. search_space

Updates

  • 2020.6 The search code is released, including both MobileNetV2- and ResNet- based search space.

Requirements

  • pytorch >= 1.0.1
  • python >= 3.6

Search

  1. Prepare the image set for search which contains 100 classes of the original ImageNet dataset. And 20% images are used as the validation set and 80% are used as the training set.

    1). Generate the split list of the image data.
    python dataset/mk_split_img_list.py --image_path 'the path of your ImageNet data' --output_path 'the path to output the list file'

    2). Use the image list obtained above to make the lmdb file.
    python dataset/img2lmdb.py --image_path 'the path of your ImageNet data' --list_path 'the path of your image list generated above' --output_path 'the path to output the lmdb file' --split 'split folder (train/val)'

  2. Build the latency lookup table (lut) of the search space using the following script or directly use the ones provided in ./latency_list/.
    python -m run_apis.latency_measure --save 'output path' --input_size 'the input image size' --meas_times 'the times of op measurement' --list_name 'the name of the output lut' --device 'gpu or cpu' --config 'the path of the yaml config'

  3. Search for the architectures. (We perform the search process on 4 32G V100 GPUs.)
    For MobileNetV2 search:
    python -m run_apis.search --data_path 'the path of the split dataset' --config configs/imagenet_search_cfg_mbv2.yaml
    For ResNet search:
    python -m run_apis.search --data_path 'the path of the split dataset' --config configs/imagenet_search_cfg_resnet.yaml

Train

  1. (Optional) We pack the ImageNet data as the lmdb file for faster IO. The lmdb files can be made as follows. If you don't want to use lmdb data, just set __C.data.train_data_type='img' in the training config file imagenet_train_cfg.py.

    1). Generate the list of the image data.
    python dataset/mk_img_list.py --image_path 'the path of your image data' --output_path 'the path to output the list file'

    2). Use the image list obtained above to make the lmdb file.
    python dataset/img2lmdb.py --image_path 'the path of your image data' --list_path 'the path of your image list' --output_path 'the path to output the lmdb file' --split 'split folder (train/val)'

  2. Train the searched model with the following script by assigning __C.net_config with the architecture obtained in the above search process. You can also train your customized model by redefine the variable model in retrain.py.
    python -m run_apis.retrain --data_path 'The path of ImageNet data' --load_path 'The path you put the net_config of the model'

Evaluate

  1. Download the related files of the pretrained model and put net_config and weights.pt into the model_path
  2. python -m run_apis.validation --data_path 'The path of ImageNet data' --load_path 'The path you put the pre-trained model'

Results

For experiments on the MobileNetV2-based search space, DenseNAS achieves 75.3% top-1 accuracy on ImageNet with only 361MB FLOPs and 17.9ms latency on a single TITAN-XP. The larger model searched by DenseNAS achieves 76.1% accuracy with only 479M FLOPs. DenseNAS further promotes the ImageNet classification accuracies of ResNet-18, -34 and -50-B by 1.5%, 0.5% and 0.3% with 200M, 600M and 680M FLOPs reduction respectively.

The comparison of model performance on ImageNet under the MobileNetV2-based search spaces.

The comparison of model performance on ImageNet under the ResNet-based search spaces.

Our pre-trained models can be downloaded in the following links. The complete list of the models can be found in DenseNAS_modelzoo.

Model FLOPs Latency Top-1(%)
DenseNAS-Large 479M 28.9ms 76.1
DenseNAS-A 251M 13.6ms 73.1
DenseNAS-B 314M 15.4ms 74.6
DenseNAS-C 361M 17.9ms 75.3
DenseNAS-R1 1.61B 12.0ms 73.5
DenseNAS-R2 3.06B 22.2ms 75.8
DenseNAS-R3 3.41B 41.7ms 78.0

archs

Citation

If you find this repository/work helpful in your research, welcome to cite it.

@inproceedings{fang2019densely,
  title={Densely connected search space for more flexible neural architecture search},
  author={Fang, Jiemin and Sun, Yuzhu and Zhang, Qian and Li, Yuan and Liu, Wenyu and Wang, Xinggang},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  year={2020}
}
Comments
  • How to get models with different latencies using search process?

    How to get models with different latencies using search process?

    Hi Jamin,

    Thanks for releasing search code. I ran search process with my custom latency table. After search process got over, it printed three network configs with 465M MAC, 437M MAC and 463M MAC. How do I generate lower latency models like how you were getting for DenseNet-A, B, C (13 ms, 15ms, 17ms)? Actually my objective is to get best model for the specific latency.

    Also in this work is there any notion of target latency like in ProxynetNAS where loss term contains penalty to have higher latency than the target latency? Which was making sure that when search process ends, searched model has latency close to target latency. loss=LossCE+ λ1|w|^2 + λ2*E[latency]

    Thanks in advance.

    opened by soyebn 8
  • index out of range

    index out of range

    Hi, sorry to bother you,i just have a question: how to deal with the problem about list index out of range in the second part of search and in MobileNetV2 search part?

    opened by Chtt-123 8
  • architecture derived problem

    architecture derived problem

    Hello, thanks for your works. When I test your code, I found a problem that confuses me a lot. When I run the search relevant scripts, I found that the super_model tends to choose the small kernel&ratio operation at final in class 'ArchGenerate'. I wonder if I do sth wrong during my test. Here are some parts of log files which prove my problems.

    #################### 11/19 11:16:15 Derived arch: [[16, 16], 'mbconv_k3_t1', [], 0, 1]| [[16, 24], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k7_t6'], 2, 2]| [[24, 48], 'mbconv_k7_t6', ['mbconv_k7_t6'], 1, 2]| [[48, 72], 'mbconv_k5_t6', ['mbconv_k5_t3', 'mbconv_k7_t6', 'mbconv_k7_t6'], 3, 2]| [[72, 128], 'mbconv_k3_t6', ['mbconv_k7_t6', 'mbconv_k7_t3'], 2, 1]| [[128, 192], 'mbconv_k7_t6', ['mbconv_k5_t3', 'mbconv_k7_t6', 'mbconv_k7_t6'], 3, 2]| [[192, 384], 'mbconv_k5_t3', [], 0, 1]| [[384, 1984], 'conv1_1'] 11/19 11:16:15 Total 19 layers. 11/19 11:16:15 Derived Model Mult-Adds = 424.00MB 11/19 11:16:15 Derived Model Num Params = 5.42MB 11/19 11:16:16 epoch 6 weight_lr 1.992126e-01 #######################

    It seems normal before it updates the architecture(before epoch 50) and tends to choose the smallest kernel&ratio after epoch 50.

    ####################### 11/20 02:14:01 Derived arch: [[16, 16], 'mbconv_k3_t1', [], 0, 1]| [[16, 24], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k3_t3', 'mbconv_k3_t3'], 3, 2]| [[24, 48], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k3_t3', 'mbconv_k3_t3'], 3, 2]| [[48, 72], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k3_t3', 'mbconv_k3_t3'], 3, 2]| [[72, 128], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k3_t3', 'mbconv_k3_t3'], 3, 1]| [[128, 192], 'mbconv_k3_t3', ['mbconv_k3_t3', 'mbconv_k3_t3', 'mbconv_k3_t3'], 3, 2]| [[192, 384], 'mbconv_k3_t3', [], 0, 1]| [[384, 1984], 'conv1_1'] 11/20 02:14:01 Total 23 layers. 11/20 02:14:01 Derived Model Mult-Adds = 306.19MB 11/20 02:14:01 Derived Model Num Params = 4.46MB 11/20 02:14:02 epoch 54 arch_lr 3.000000e-04 ########################

    And it almost doesn't change til the end. I wonder how this phenomenon happens. Hope for your reply!

    opened by mileswyn 6
  • Sub loss factor in ResNet-based search space

    Sub loss factor in ResNet-based search space

    Hi, thanks for your great work.

    Could you please provide the sub loss factor corresponding to DenseNAS-R1 and DenseNAS-R2 respectively for chained cost estimation. I can not find it in the paper and default value in the code is 0.2.

    Thank you.

    opened by Debrove 4
  • 关于DenseNAS中stage的疑问

    关于DenseNAS中stage的疑问

    您好,有一个问题想请教一下,DenseNAS中的stage与Mobilenetv2中的stage貌似不是对应的? mobilenetv2中由7个stage,19个residual block,与论文中的Figure4所展示出来的不一样

    您论文里面的mobilenetv2-based是网络结构中的operation包含MBconv的意思么?如果是的话,DenseNAS中的stage数是怎么确定的?

    opened by LianShuaiLong 4
  • Script for search

    Script for search

    In another issue you mentioned "The code of the search space is released." How do I start search process ? Do you have script similar to run_apis.retrain?

    Btw I am the same guy who posted a question on your another work, FNA. :-)

    opened by soyebn 3
  • Some questions about the search stage

    Some questions about the search stage

    Hi, I am currently trying to reproduce the search process for the default configuration. Could you please provide the following information:

    1. The names of 100 classes and, if possible, the full names of the files used in train and validation splits, since their obtaining in the code is platform-dependent
    2. The specific version of pytorch used, since in the version 1.6.0 there is a bug related to DataParallel and replication of architecture parameters to other gpus (for example, https://github.com/pytorch/pytorch/issues/36035). In this regard, the search stage does not work in multi-gpu enviroment
    3. Log files (log.txt) for search and train stages with default config file (if I understand correctly it matches DenseNAS-C model)
    opened by Lorien2027 2
  • retrain阶段的net_config问题

    retrain阶段的net_config问题

    您好,有一个问题想请教一下,我在跑完search阶段,准备运行retrain,请问运行时候的net_config文件是再第一个阶段自动生成的么?我的output里面只有excel_record,weights_*.pt这些文件,并没有找到net_config文件,请问是我search阶段出现什么问题了么?

    opened by LianShuaiLong 2
  • Preparation of the dataset

    Preparation of the dataset

    Hi, thanks for your interesting work. How do you organize your training data? In folder imagenet/train there are sub-folders like nxxx. But when using mk_split_img_list.py to split the training data, it may skip the folders as follows:

    if not os.path.isdir(split_path):
        continue
    
    opened by colorjam 2
  • Could you please tell me something about your strategy

    Could you please tell me something about your strategy

    In the traditional darts methods, weights and architecture are optimized step by step, but in your paper, weights and architecture are optimized by epoch, is it mean that in this epoch,the model optimizes weights and in the next epoch, the model optimizes the architecture. I am quite confused.

    opened by HONGJUNRL 2
  • some questions about the code

    some questions about the code

    您好,有一些代码上的问题想要请教一下,我看search.py这个脚本里面,有一些类似下面 super_model.module.display_arch_params() 的操作: betas, head_alphas, stack_alphas = super_model.module.display_arch_params() 请问这些函数是在哪里定义的?在nn.module的方法中我没有找到对应的api

    opened by LianShuaiLong 1
  • Search on CIFAR10

    Search on CIFAR10

    Hi,

    Thanks for open-sourcing this work. I was wondering how to search for a DenseNAS model on CIFAR10 based on ResNet. I have resolved the data loading issue. But for the specification of the search space, I was struggling to make the configuration correct. Because the input size of CIFAR10 is 32*32, I think I need to modify the net_scale, init_dim, and last_dim in imagenet_search_cfg_resnet.yaml. So I remove seven entries in each list in net_scale. But I encountered this error:

    Original Traceback (most recent call last):
      File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
        output = module(*input, **kwargs)
      File "/usr/local/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
        result = self.forward(*input, **kwargs)
      File "/home/xx/code/DenseNAS/models/dropped_model.py", line 155, in forward
        betas = [branch_weights[block_id][beta_id]
      File "/home/xx/code/DenseNAS/models/dropped_model.py", line 155, in <listcomp>
        betas = [branch_weights[block_id][beta_id]
    IndexError: list index out of range
    

    I greatly appreciate it if you could tell me how to resolve this issue and perform the search on CIFAR10.

    opened by youweiliang 0
  • How to execute your codes?

    How to execute your codes?

    Hi! Thanks for sharing your great work! I have some questions to ask you.

    How to execute your codes? What is the order of executing your codes? If I use your code which paper should be referenced?

    Thank you very much! Best regards, Liu Jiaqi

    opened by Ljiaqii 0
  • 請問正確的路徑配置?

    請問正確的路徑配置?

    感謝您們釋出這麼棒的研究工作!

    在使用你們模組時遇到困難, 想請問, Search區塊裡:

    1.Prepare the image set for search which contains 100 classes of the original ImageNet dataset. And 20% images are used as the validation set and 80% are used as the training set.

    1). Generate the split list of the image data. python dataset/mk_split_img_list.py --image_path 'the path of your ImageNet data' --output_path 'the path to output the list file'

    2). Use the image list obtained above to make the lmdb file. python dataset/img2lmdb.py --image_path 'the path of your ImageNet data' --list_path 'the path of your image list generated above' --output_path 'the path to output the lmdb file' --split 'split folder (train/val)'' ...

    詳盡的路徑配置和各個floder裡面包含的架構與內容?

    從ImageNet下載datasets, 經過各種設置的嘗試, 都沒有成功.

    謝謝.

    opened by BenoitKAO 1
  • no random noise in gumbelsoftmax?

    no random noise in gumbelsoftmax?

    hello: do you use gumbelsoftmax? i wonder why don't you add random noise in gumbelsoftmax and the temperature doesn't change in whole training process? thanks

    opened by bysowhat 1
  • 有关代码的一些问题

    有关代码的一些问题

    您好,非常赞赏你们的工作,有两个地方不太理解,想请教一下。 1 论文中讲到需要有2 个更新的参数,一个是在head layer 里用于选择从前面哪个通道的block中接收输入,还有一个是 stack layer里操作的选择。但是在代码里,却有3个参数,分别是 betas, head_alphas, stack_alphas ,多出来了一个是有关本block输出可以去向哪些block的,这样设置的作用是什么? 2 数据集被分成了train和valid两个部分,在weights更新的步骤里用的是train数据,在arch更新的步骤里用的是valid数据,但是在infer时用的还是valid数据,这部分数据不应该已经被网络学习过了吗?是不是应该用其他的数据再去做infer? 这是我想不明白的2个问题,想请您帮忙解答一下,哪里理解地不对请您指正。

    opened by SZLGZYD 4
EDCNN: Edge enhancement-based Densely Connected Network with Compound Loss for Low-Dose CT Denoising

EDCNN: Edge enhancement-based Densely Connected Network with Compound Loss for Low-Dose CT Denoising By Tengfei Liang, Yi Jin, Yidong Li, Tao Wang. Th

workingcoder 115 Jan 5, 2023
(IEEE TIP 2021) Regularized Densely-connected Pyramid Network for Salient Instance Segmentation

RDPNet IEEE TIP 2021: Regularized Densely-connected Pyramid Network for Salient Instance Segmentation PyTorch training and testing code are available.

Yu-Huan Wu 41 Oct 21, 2022
code for paper "Does Unsupervised Architecture Representation Learning Help Neural Architecture Search?"

Does Unsupervised Architecture Representation Learning Help Neural Architecture Search? Code for paper: Does Unsupervised Architecture Representation

null 39 Dec 17, 2022
RCDNet: A Model-driven Deep Neural Network for Single Image Rain Removal (CVPR2020)

RCDNet: A Model-driven Deep Neural Network for Single Image Rain Removal (CVPR2020) Hong Wang, Qi Xie, Qian Zhao, and Deyu Meng [PDF] [Supplementary M

Hong Wang 6 Sep 27, 2022
DeepHyper: Scalable Asynchronous Neural Architecture and Hyperparameter Search for Deep Neural Networks

What is DeepHyper? DeepHyper is a software package that uses learning, optimization, and parallel computing to automate the design and development of

DeepHyper Team 214 Jan 8, 2023
This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural tree born form a large search space

SeBoW: Self-Born Wiring for neural trees(PaddlePaddle version) This is the paddle code for SeBoW(Self-Born wiring for neural trees), a kind of neural

HollyLee 13 Dec 8, 2022
[CVPR 2021] 'Searching by Generating: Flexible and Efficient One-Shot NAS with Architecture Generator'

[CVPR2021] Searching by Generating: Flexible and Efficient One-Shot NAS with Architecture Generator Overview This is the entire codebase for the paper

null 35 Dec 1, 2022
FuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space OptimizationFuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space Optimization

FuseDream This repo contains code for our paper (paper link): FuseDream: Training-Free Text-to-Image Generation with Improved CLIP+GAN Space Optimizat

XCL 191 Dec 31, 2022
Space robot - (Course Project) Using the space robot to capture the target satellite that is disabled and spinning, then stabilize and fix it up

Space robot - (Course Project) Using the space robot to capture the target satellite that is disabled and spinning, then stabilize and fix it up

Mingrui Yu 3 Jan 7, 2022
PyTorch reimplementation of minimal-hand (CVPR2020)

Minimal Hand Pytorch Unofficial PyTorch reimplementation of minimal-hand (CVPR2020). you can also find in youtube or bilibili bare hand youtube or bil

Hao Meng 228 Dec 29, 2022
Code for the Active Speakers in Context Paper (CVPR2020)

Active Speakers in Context This repo contains the official code and models for the "Active Speakers in Context" CVPR 2020 paper. Before Training The c

null 43 Oct 14, 2022
Code for Referring Image Segmentation via Cross-Modal Progressive Comprehension, CVPR2020.

CMPC-Refseg Code of our CVPR 2020 paper Referring Image Segmentation via Cross-Modal Progressive Comprehension. Shaofei Huang*, Tianrui Hui*, Si Liu,

spyflying 55 Dec 1, 2022
This is an implementation for the CVPR2020 paper "Learning Invariant Representation for Unsupervised Image Restoration"

Learning Invariant Representation for Unsupervised Image Restoration (CVPR 2020) Introduction This is an implementation for the paper "Learning Invari

GarField 88 Nov 7, 2022
Pytorch implementation of CVPR2020 paper “VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation”

VectorNet Re-implementation This is the unofficial pytorch implementation of CVPR2020 paper "VectorNet: Encoding HD Maps and Agent Dynamics from Vecto

null 120 Jan 6, 2023
An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020

UnpairedSR An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020 turn RCAN(modified) --> xmodel(xilinx

JiaKui Hu 10 Oct 28, 2022
Super Pix Adv - Offical implemention of Robust Superpixel-Guided Attentional Adversarial Attack (CVPR2020)

Super_Pix_Adv Offical implemention of Robust Superpixel-Guided Attentional Adver

DLight 8 Oct 26, 2022
Model search is a framework that implements AutoML algorithms for model architecture search at scale

Model search (MS) is a framework that implements AutoML algorithms for model architecture search at scale. It aims to help researchers speed up their exploration process for finding the right model architecture for their classification problems (i.e., DNNs with different types of layers).

Google 3.2k Dec 31, 2022
[ICLR 2021] "Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective" by Wuyang Chen, Xinyu Gong, Zhangyang Wang

Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective [PDF] Wuyang Chen, Xinyu Gong, Zhangyang Wang In ICLR 2

VITA 156 Nov 28, 2022
[ICLR 2021] HW-NAS-Bench: Hardware-Aware Neural Architecture Search Benchmark

HW-NAS-Bench: Hardware-Aware Neural Architecture Search Benchmark Accepted as a spotlight paper at ICLR 2021. Table of content File structure Prerequi

null 72 Jan 3, 2023