Git Product home page Git Product logo

regnet-search-pytorch's Introduction

Search-RegNet-PyTorch

Implemention for neural architecture search of RegNet using PyTorch and AutoTorch.

This example and Fast AutoAugment will be used in the tutorial on From HPO to NAS: Automated Deep Learning at CVPR 2020.

model ref Acc config
RegNet-0.4GF official 72.38 link
RegNet-0.4GF ours 72.18 link
RegNet-4.0GF official 79.03 link

official: using official configuration. ours: using our searched configuration.

Training HP setting: learning rate: 0.2, batch size: 512, weight decay: 1e-4,

Quick Start

Install Dependencies

  • Install PyTorch, following the instruction.
  • Install other dependencies:
pip install autotorch thop torch-encoding
  • Install Apex (optional):
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

Test #Params and FLOPs from config file

python test_flops.py --config-file configs/RegNetX-4.0GF.ini

Single Model Training

Prepare ImageNet Dataset

cd scripts/
# assuming you have downloaded the dataset in the current folder
python prepare_imagenet.py --download-dir ./

Train a single model from a config file

python train.py --dataset imagenet --config-file configs/RegNetX-4.0GF.ini --lr-scheduler cos --epochs 120 --checkname default --lr 0.025 --batch-size 64 --amp

Architecture Search

Generate config files with expected GFLOPs

python generate_configs.py --gflops 4 --num-configs 32 --config-file configs/RegNetX-4.0GF

The generated configuration files will be saved as configs/RegNetX-4.0GF-1.ini, configs/RegNetX-4.0GF-2.ini ...

Search best model for the config files in a folder

In this example, each model will be trained using a single gpu for 25 epochs.

python search.py --config-file-folder gen_configs/RegNet-0.4GF/ --output-folder out_configs/ --epochs 25

The accuracy will be written into the output config file after training.

regnet-search-pytorch's People

Contributors

zhanghang1989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

regnet-search-pytorch's Issues

Quick Start error

I followed the quick start step,util No module named 'arch'. I solved it with pip install arch.
However,when i runpython test_regnet.py --config-file RegNet-Search-PyTorch/configs/RegNetX-4.0GF.ini ,it get a similar problem which is ModuleNotFoundError: No module named 'arch.regnet'

To be specific,
(pytorch-OpCounter) root@w-16:~/wxb/pytorch-OpCounter/benchmark# python test_regnet.py --config-file RegNet-Search-PyTorch/configs/RegNetX-4.0GF.ini Traceback (most recent call last): File "evaluate_regnet_zyx.py", line 41, in <module> main() File "evaluate_regnet_zyx.py", line 28, in main arch = importlib.import_module('arch.' + args.arch) File "/root/anaconda2/envs/pytorch-OpCounter/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'arch.regnet'

MXNet reimplement

Good job, but I have some questions:

  1. It is known to all that FAIR's RegNet source code had released(pycls codebase), so what's the difference ?(RegNet-0.4GF is 0.2% less than official) and why u reimplement ?
  2. Have u and your team use MXNet or gluon to implement RegNet? If not, why? Does phenomenon implies Pytorch more usability than MXNet ?

Thanks.

design ShuffleNetV2 search space

Thanks for your excellent work!
Are the search criteria in regnet suitable for ShuffleNetV2? If I want to search a shuffleNet model with FLOPs 60M, can I design a search space based on this code?

C++ error

hello,When I run search.py,I find a error like this.
image
My pytorch version is 1.4.0. Thank you.

About some warnings

I got the fllowing logs after running: python test_flops.py --config-file configs/RegNetX-4.0GF.ini,i wonder whether these warnings are normal?

[INFO] Register count_convNd() for <class 'torch.nn.modules.conv.Conv2d'>.
[INFO] Register count_bn() for <class 'torch.nn.modules.batchnorm.BatchNorm2d'>.
[INFO] Register zero_ops() for <class 'torch.nn.modules.activation.ReLU'>.
[WARN] Cannot find rule for <class 'arch.regnet.ConvBnAct'>. Treat it as zero Macs and zero Params.
[WARN] Cannot find rule for <class 'arch.regnet.Bottleneck'>. Treat it as zero Macs and zero Params.
[WARN] Cannot find rule for <class 'torch.nn.modules.container.Sequential'>. Treat it as zero Macs and zero Params.
[WARN] Cannot find rule for <class 'arch.regnet.Stage'>. Treat it as zero Macs and zero Params.
[WARN] Cannot find rule for <class 'arch.regnet.GlobalAvgPool2d'>. Treat it as zero Macs and zero Params.

[INFO] Register count_linear() for <class 'torch.nn.modules.linear.Linear'>.
[WARN] Cannot find rule for <class 'arch.regnet.RegNet'>. Treat it as zero Macs and zero Params.
macs: 3.989G, params: 22.118M

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.