{"id":22354737,"url":"https://github.com/pprp/ofa-cifar","last_synced_at":"2025-03-26T12:41:52.955Z","repository":{"id":47963354,"uuid":"403445881","full_name":"pprp/ofa-cifar","owner":"pprp","description":":star: Make Once for All support CIFAR10 dataset.","archived":false,"fork":false,"pushed_at":"2021-09-11T00:35:29.000Z","size":3005,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T13:43:54.717Z","etag":null,"topics":["cifar10","cifar10-classification","nas","neural-architecture-search"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pprp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-06T00:58:49.000Z","updated_at":"2022-07-21T15:32:33.000Z","dependencies_parsed_at":"2022-08-12T15:20:41.243Z","dependency_job_id":null,"html_url":"https://github.com/pprp/ofa-cifar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fofa-cifar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fofa-cifar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fofa-cifar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fofa-cifar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pprp","download_url":"https://codeload.github.com/pprp/ofa-cifar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245658981,"owners_count":20651519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cifar10","cifar10-classification","nas","neural-architecture-search"],"created_at":"2024-12-04T13:15:00.801Z","updated_at":"2025-03-26T12:41:52.926Z","avatar_url":"https://github.com/pprp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Once for All - CIFAR10\n\n[TOC]\n\n## Introduction\n\n[Once for all](https://github.com/mit-han-lab/once-for-all) is an one-stage one-shot Neural Architecture Search Algorithm, which mainly support ImageNet Datasets. \n\nIn this repository, most codes are from https://github.com/mit-han-lab/once-for-all.\n\nWe mainly focus on training OFA(Once for all) on CIFAR10 dataset. \n\nWhat we do:\n\n- Support CIFAR10 dataloader\n- Modify training codes\n- Support Single GPU Training\n- Rewrite code about Max Teachernet Training\n- Release TeacherNet weight(Coming soon..)\n\n\n\n## How to train **OFA Networks**\n\n```bash\nmpirun -np 32 -H \u003cserver1_ip\u003e:8,\u003cserver2_ip\u003e:8,\u003cserver3_ip\u003e:8,\u003cserver4_ip\u003e:8 \\\n    -bind-to none -map-by slot \\\n    -x NCCL_DEBUG=INFO -x LD_LIBRARY_PATH -x PATH \\\n    python train_ofa_net.py\n```\n\nor \n\n```bash\nhorovodrun -np 32 -H \u003cserver1_ip\u003e:8,\u003cserver2_ip\u003e:8,\u003cserver3_ip\u003e:8,\u003cserver4_ip\u003e:8 \\\n    python train_ofa_net.py\n```\n\n## Requirement\n\n* Python 3.6+\n* Pytorch 1.4.0+\n* ImageNet Dataset \n* Horovod\n\n## How to use / evaluate **OFA Networks**\n### Use\n```python\n\"\"\" OFA Networks.\n    Example: ofa_network = ofa_net('ofa_mbv3_d234_e346_k357_w1.0', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_net\nofa_network = ofa_net(net_id, pretrained=True)\n    \n# Randomly sample sub-networks from OFA network\nofa_network.sample_active_subnet()\nrandom_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n    \n# Manually set the sub-network\nofa_network.set_active_subnet(ks=7, e=6, d=4)\nmanual_subnet = ofa_network.get_active_subnet(preserve_weight=True)\n```\nIf the above scripts failed to download, you download it manually from [Google Drive](https://drive.google.com/drive/folders/10leLmIiMtaRu4J46KwrBaMydvQt0qFuI?usp=sharing) and put them under $HOME/.torch/ofa_nets/.\n\n### Evaluate\n\n```\npython eval_ofa_net.py --path 'Your path to imagenet' --net ofa_mbv3_d234_e346_k357_w1.0 \n```\n\n## How to use / evaluate **OFA Specialized Networks** \n### Use\n```python\n\"\"\" OFA Specialized Networks.\nExample: net, image_size = ofa_specialized('flops@595M_top1@80.0_finetune@75', pretrained=True)\n\"\"\" \nfrom ofa.model_zoo import ofa_specialized\nnet, image_size = ofa_specialized(net_id, pretrained=True)\n```\nIf the above scripts failed to download, you download it manually from [Google Drive](https://drive.google.com/drive/folders/1ez-t_DAHDet2fqe9TZUTJmvrU-AwofAt?usp=sharing) and put them under $HOME/.torch/ofa_specialized/.\n\n### Evaluate\n```\npython eval_specialized_net.py --path 'Your path to imagent' --net flops@595M_top1@80.0_finetune@75 \n```\n\n![](figures/cnn_imagenet_new.png)\n\n\n\n```BibTex\n@inproceedings{\n  cai2020once,\n  title={Once for All: Train One Network and Specialize it for Efficient Deployment},\n  author={Han Cai and Chuang Gan and Tianzhe Wang and Zhekai Zhang and Song Han},\n  booktitle={International Conference on Learning Representations},\n  year={2020},\n  url={https://arxiv.org/pdf/1908.09791.pdf}\n}\n```\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprp%2Fofa-cifar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpprp%2Fofa-cifar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprp%2Fofa-cifar/lists"}