Once for All: Train One Network and Specialize it for Efficient Deployment [arXiv] [Slides] [Video]
@inproceedings{
cai2020once,
title={Once for All: Train One Network and Specialize it for Efficient Deployment},
author={Han Cai and Chuang Gan and Tianzhe Wang and Zhekai Zhang and Song Han},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://arxiv.org/pdf/1908.09791.pdf}
}
News
- Fisrt place in the 4th Low-Power Computer Vision Challenge, both classification and detection track.
- First place in the 3rd Low-Power Computer Vision Challenge, DSP track at ICCV’19 using the Once-for-all Network.
Train once, specialize for many deployment scenarios
80% top1 ImageNet accuracy under mobile setting
Consistently outperforms MobileNetV3 on Diverse hardware platforms
How to use / evaluate OFA Specialized Networks
Use
""" OFA Specialized Networks.
Example: net, image_size = ofa_specialized('flops@595M_top1@80.0_finetune@75', pretrained=True)
"""
from ofa.model_zoo import ofa_specialized
net, image_size = ofa_specialized(net_id, pretrained=True)
If the above scripts failed to download, you download it manually from Google Drive and put them under $HOME/.torch/ofa_specialized/.
Evaluate
python eval_specialized_net.py --path 'Your path to imagent' --net flops@595M_top1@80.0_finetune@75
OFA based on FLOPs
- flops@595M_top1@80.0_finetune@75
- flops@482M_top1@79.6_finetune@75
- flops@389M_top1@79.1_finetune@75
OFA for Mobile Phones
|
LG G8
|
Samsung Note8
|
|
Google Pixel1
|
Samsung Note10
|
|
Google Pixel2
|
Samsung S7 Edge
|
OFA for Desktop (CPUs and GPUs)
|
1080ti GPU (Batch Size 64)
|
V100 GPU (Batch Size 64)
|
|
Jetson TX2 GPU (Batch Size 16)
|
Intel Xeon CPU with MKL-DNN (Batch Size 1)
|
How to use / evaluate OFA Networks
Use
""" OFA Networks.
Example: ofa_network = ofa_net('ofa_mbv3_d234_e346_k357_w1.0', pretrained=True)
"""
from ofa.model_zoo import ofa_net
ofa_network = ofa_net(net_id, pretrained=True)
# Randomly sample sub-networks from OFA network
ofa_network.sample_active_subnet()
random_subnet = ofa_network.get_active_subnet(preserve_weight=True)
# Manually set the sub-network
ofa_network.set_active_subnet(ks=7, e=6, d=4)
manual_subnet = ofa_network.get_active_subnet(preserve_weight=True)
If the above scripts failed to download, you download it manually from Google Drive and put them under $HOME/.torch/ofa_nets/.
Evaluate
python eval_ofa_net.py --path 'Your path to imagenet' --net ofa_mbv3_d234_e346_k357_w1.0
How to train OFA Networks
mpirun -np 32 -H <server1_ip>:8,<server2_ip>:8,<server3_ip>:8,<server4_ip>:8 \
-bind-to none -map-by slot \
-x NCCL_DEBUG=INFO -x LD_LIBRARY_PATH -x PATH \
python train_ofa_net.py
or
horovodrun -np 32 -H <server1_ip>:8,<server2_ip>:8,<server3_ip>:8,<server4_ip>:8 \
python train_ofa_net.py
Introduction Video
Requirement
- Python 3.6
- Pytorch 1.0.0
- ImageNet Dataset
- Horovod
Related work on automated and efficient deep learning:
ProxylessNAS: Direct Neural Architecture Search on Target Task and Hardware (ICLR’19)
AutoML for Architecting Efficient and Specialized Neural Networks (IEEE Micro)
AMC: AutoML for Model Compression and Acceleration on Mobile Devices (ECCV’18)
HAQ: Hardware-Aware Automated Quantization (CVPR’19, oral)
Metadata
Release files for ofa 0.0.3-2006120228
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ofa-0.0.3.post2006120228-py3-none-any.whl | Python 3 | none | any | Details for ofa-0.0.3.post2006120228-py3-none-any.whl |
Release files / ofa-0.0.3.post2006120228-py3-none-any.whl
| Download URL | ofa-0.0.3.post2006120228-py3-none-any.whl |
|---|---|
| Size | 73.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
616680c37857c35cbec7ab7870cfd491440a8c60bd4560aaa3b3e0bfc7d65056
|
|
BLAKE2b-256 checksum How to use checksums |
9f04017e32e35b80e9dd10af125c1e065a5a7a655981ab5b63b3b42809ea6386
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for ofa 0.0.3-2006120228
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.