Update NATS-Bench (sss version 1.3)
This commit is contained in:
parent
5f151d1970
commit
e04808c14e
@ -10,11 +10,28 @@ This facilitates a much larger community of researchers to focus on developing b
|
||||
|
||||
**coming soon!**
|
||||
|
||||
The structure of this Markdown file:
|
||||
- [How to use NATS-Bench?](#How-to-Use-NATS-Bench)
|
||||
- [How to re-create NATS-Bench from scratch?](#how-to-re-create-nats-bench-from-scratch)
|
||||
- [How to reproduce benchmarked results?](#to-reproduce-13-baseline-nas-algorithms-in-nas-bench-201)
|
||||
|
||||
|
||||
## How to Use NATS-Bench
|
||||
|
||||
### Preparation and Download
|
||||
The **latest** benchmark file of NATS-Bench can be downloaded from [Google Drive](https://drive.google.com/drive/folders/1zjB6wMANiKwB2A1yil2hQ8H_qyeSe2yt?usp=sharing).
|
||||
We highly recommend to put the downloaded benchmark file (`NATS-sss-v1_0-50262.pickle.pbz2`) or uncompressed archive (`NATS-sss-v1_0-50262-simple`) into `$TORCH_HOME`.
|
||||
In this way, our api will automatically find the path for these benchmarkfiles, which is convenient for the users. Otherwise, you need to manually indicate the file when creating the benchmark instance.
|
||||
|
||||
The history of benchmark files are as follows, `tss` indicates the topology search space and `sss` indicates the size search space.
|
||||
The benchmark file is used when create the NATS-Bench instance with `fast_mode=False`.
|
||||
The archive is used when `fast_mode=True`, where `archive` is a directory contains 15,625 files for tss or contains 32,768 files for sss. Each file contains all the information for a specific architecture candidate.
|
||||
The `full archive` is similar to `archive`, while each file in `full archive` contains **the trained weights**.
|
||||
|
||||
| Date | benchmark file (tss) | archive (tss) | full archive (tss) | benchmark file (sss) | archive (sss) | full archive (sss) |
|
||||
|:-----------|:---------------------:|:-------------:|:------------------:|:-------------------------------:|:--------------------------:|:------------------:|
|
||||
| 2020.08.31 | | | | NATS-sss-v1_0-50262.pickle.pbz2 | NATS-sss-v1_0-50262-simple | [xx]-full |
|
||||
|
||||
|
||||
1, create the benchmark instance:
|
||||
```
|
||||
@ -22,11 +39,12 @@ api = create(None, 'sss', fast_mode=True, verbose=True)
|
||||
```
|
||||
|
||||
|
||||
## The Procedure of Creating NATS-Bench
|
||||
## How to Re-create NATS-Bench from Scratch
|
||||
|
||||
### The Size Search Space
|
||||
|
||||
The following command will train all architecture candidate in the size search space with 90 epochs and use the random seed of `777`. If you want to use a different number of training epochs, please replace `90` with it, such as `01` or `12`. If you want to use a different
|
||||
The following command will train all architecture candidate in the size search space with 90 epochs and use the random seed of `777`.
|
||||
If you want to use a different number of training epochs, please replace `90` with it, such as `01` or `12`.
|
||||
```
|
||||
bash ./scripts/NATS-Bench/train-shapes.sh 00000-32767 90 777
|
||||
```
|
||||
@ -35,6 +53,13 @@ The checkpoint of all candidates are located at `output/NATS-Bench-size` by defa
|
||||
|
||||
### The Topology Search Space
|
||||
|
||||
The following command will train all architecture candidate in the topology search space with 200 epochs and use the random seed of `777`/`888`/`999`.
|
||||
If you want to use a different number of training epochs, please replace `200` with it, such as `12`.
|
||||
```
|
||||
bash scripts/NATS-Bench/train-topology.sh 00000-15624 200 '777 888 999'
|
||||
```
|
||||
The checkpoint of all candidates are located at `output/NATS-Bench-topology` by default.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -42,13 +67,20 @@ The checkpoint of all candidates are located at `output/NATS-Bench-size` by defa
|
||||
|
||||
### Reproduce NAS methods on the topology search space
|
||||
|
||||
Please use the following commands to run different NAS methods on the topology search space:
|
||||
```
|
||||
DARTS (V1):
|
||||
Four multi-trial based methods:
|
||||
python ./exps/NATS-algos/reinforce.py --dataset cifar100 --search_space tss --learning_rate 0.01
|
||||
python ./exps/NATS-algos/regularized_ea.py --dataset cifar100 --search_space tss --ea_cycles 200 --ea_population 10 --ea_sample_size 3
|
||||
python ./exps/NATS-algos/random_wo_share.py --dataset cifar100 --search_space tss
|
||||
python ./exps/NATS-algos/bohb.py --dataset cifar100 --search_space tss --num_samples 4 --random_fraction 0.0 --bandwidth_factor 3
|
||||
|
||||
DARTS (first order):
|
||||
python ./exps/NATS-algos/search-cell.py --dataset cifar10 --data_path $TORCH_HOME/cifar.python --algo darts-v1
|
||||
python ./exps/NATS-algos/search-cell.py --dataset cifar100 --data_path $TORCH_HOME/cifar.python --algo darts-v1
|
||||
python ./exps/NATS-algos/search-cell.py --dataset ImageNet16-120 --data_path $TORCH_HOME/cifar.python/ImageNet16 --algo darts-v1
|
||||
|
||||
DARTS (V2):
|
||||
DARTS (second order):
|
||||
python ./exps/NATS-algos/search-cell.py --dataset cifar10 --data_path $TORCH_HOME/cifar.python --algo darts-v2
|
||||
python ./exps/NATS-algos/search-cell.py --dataset cifar100 --data_path $TORCH_HOME/cifar.python --algo darts-v2
|
||||
python ./exps/NATS-algos/search-cell.py --dataset ImageNet16-120 --data_path $TORCH_HOME/cifar.python/ImageNet16 --algo darts-v2
|
||||
@ -76,6 +108,34 @@ python ./exps/NATS-algos/search-cell.py --dataset ImageNet16-120 --data_path $TO
|
||||
|
||||
### Reproduce NAS methods on the size search space
|
||||
|
||||
Please use the following commands to run different NAS methods on the size search space:
|
||||
```
|
||||
Four multi-trial based methods:
|
||||
python ./exps/NATS-algos/reinforce.py --dataset cifar100 --search_space sss --learning_rate 0.01
|
||||
python ./exps/NATS-algos/regularized_ea.py --dataset cifar100 --search_space sss --ea_cycles 200 --ea_population 10 --ea_sample_size 3
|
||||
python ./exps/NATS-algos/random_wo_share.py --dataset cifar100 --search_space sss
|
||||
|
||||
|
||||
Run Transformable Architecture Search (TAS), proposed in Network Pruning via Transformable Architecture Search, NeurIPS 2019
|
||||
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar10 --data_path $TORCH_HOME/cifar.python --algo tas --rand_seed 777
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar100 --data_path $TORCH_HOME/cifar.python --algo tas --rand_seed 777
|
||||
python ./exps/NATS-algos/search-size.py --dataset ImageNet16-120 --data_path $TORCH_HOME/cifar.python/ImageNet16 --algo tas --rand_seed 777
|
||||
|
||||
|
||||
Run the search strategy in FBNet-V2
|
||||
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar10 --data_path $TORCH_HOME/cifar.python --algo fbv2 --rand_seed 777
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar100 --data_path $TORCH_HOME/cifar.python --algo fbv2 --rand_seed 777
|
||||
python ./exps/NATS-algos/search-size.py --dataset ImageNet16-120 --data_path $TORCH_HOME/cifar.python/ImageNet16 --algo fbv2 --rand_seed 777
|
||||
|
||||
|
||||
Run the search strategy in TuNAS:
|
||||
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar10 --data_path $TORCH_HOME/cifar.python --algo tunas --arch_weight_decay 0 --rand_seed 777 --use_api 0
|
||||
python ./exps/NATS-algos/search-size.py --dataset cifar100 --data_path $TORCH_HOME/cifar.python --algo tunas --arch_weight_decay 0 --rand_seed 777
|
||||
python ./exps/NATS-algos/search-size.py --dataset ImageNet16-120 --data_path $TORCH_HOME/cifar.python/ImageNet16 --algo tunas --arch_weight_decay 0 --rand_seed 777
|
||||
```
|
||||
|
||||
### Final Discovered Architectures for Each Algorithm
|
||||
|
||||
@ -83,12 +143,12 @@ The architecture index can be found by use `api.query_index_by_arch(architecture
|
||||
|
||||
The final discovered architecture ID on CIFAR-10:
|
||||
```
|
||||
DARTS (V1):
|
||||
DARTS (first order):
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|
||||
DARTS (V2):
|
||||
DARTS (second order):
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|skip_connect~1|skip_connect~2|
|
||||
|
@ -25,7 +25,7 @@ from nats_bench import pickle_save, pickle_load, ArchResults, ResultsCount
|
||||
from procedures import bench_pure_evaluate as pure_evaluate, get_nas_bench_loaders
|
||||
from utils import get_md5_file
|
||||
|
||||
NATS_TSS_BASE_NAME = 'NATS-tss-v1_0' # 2020.08.28
|
||||
NATS_SSS_BASE_NAME = 'NATS-sss-v1_0' # 2020.08.28
|
||||
|
||||
|
||||
def account_one_arch(arch_index: int, arch_str: Text, checkpoints: List[Text], datasets: List[Text]) -> ArchResults:
|
||||
@ -234,12 +234,12 @@ def simplify(save_dir, save_name, nets, total):
|
||||
pickle_save(final_infos, str(save_file_name))
|
||||
# move the benchmark file to a new path
|
||||
hd5sum = get_md5_file(str(save_file_name) + '.pbz2')
|
||||
hd5_file_name = save_dir / '{:}-{:}.pickle.pbz2'.format(NATS_TSS_BASE_NAME, hd5sum)
|
||||
hd5_file_name = save_dir / '{:}-{:}.pickle.pbz2'.format(NATS_SSS_BASE_NAME, hd5sum)
|
||||
shutil.move(str(save_file_name) + '.pbz2', hd5_file_name)
|
||||
print('Save {:} / {:} architecture results into {:} -> {:}.'.format(len(evaluated_indexes), total, save_file_name, hd5_file_name))
|
||||
# move the directory to a new path
|
||||
hd5_full_save_dir = save_dir / '{:}-{:}-full'.format(NATS_TSS_BASE_NAME, hd5sum)
|
||||
hd5_simple_save_dir = save_dir / '{:}-{:}-simple'.format(NATS_TSS_BASE_NAME, hd5sum)
|
||||
hd5_full_save_dir = save_dir / '{:}-{:}-full'.format(NATS_SSS_BASE_NAME, hd5sum)
|
||||
hd5_simple_save_dir = save_dir / '{:}-{:}-simple'.format(NATS_SSS_BASE_NAME, hd5sum)
|
||||
shutil.move(full_save_dir, hd5_full_save_dir)
|
||||
shutil.move(simple_save_dir, hd5_simple_save_dir)
|
||||
# save the meta information for simple and full
|
||||
|
@ -1,5 +1,5 @@
|
||||
##############################################################################
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.07 ##########################
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.08 ##########################
|
||||
##############################################################################
|
||||
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size #
|
||||
##############################################################################
|
||||
@ -11,7 +11,7 @@ from .api_topology import NATStopology
|
||||
from .api_size import NATSsize
|
||||
|
||||
|
||||
NATS_BENCH_API_VERSIONs = ['v1.0'] # [2020.08.28]
|
||||
NATS_BENCH_API_VERSIONs = ['v1.0'] # [2020.08.31]
|
||||
|
||||
|
||||
def version():
|
||||
|
@ -1,10 +1,10 @@
|
||||
#####################################################
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.06 #
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.08 #
|
||||
##############################################################################
|
||||
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size #
|
||||
#####################################################################################
|
||||
# The history of benchmark files (the name is NATS-tss-[version]-[md5].pickle.pbz2) #
|
||||
# [2020.08.28] NATS-tss-v1_0-50262.pickle.pbz2 #
|
||||
# The history of benchmark files (the name is NATS-sss-[version]-[md5].pickle.pbz2) #
|
||||
# [2020.08.31] NATS-sss-v1_0-50262.pickle.pbz2 #
|
||||
#####################################################################################
|
||||
import os, copy, random, numpy as np
|
||||
from pathlib import Path
|
||||
@ -17,7 +17,7 @@ from .api_utils import remap_dataset_set_names
|
||||
|
||||
|
||||
PICKLE_EXT = 'pickle.pbz2'
|
||||
ALL_BASE_NAMES = ['NATS-tss-v1_0-50262']
|
||||
ALL_BASE_NAMES = ['NATS-sss-v1_0-50262']
|
||||
|
||||
|
||||
def print_information(information, extra_info=None, show=False):
|
||||
|
@ -1,20 +1,23 @@
|
||||
#####################################################
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.07 #
|
||||
############################################################################################
|
||||
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size
|
||||
############################################################################################
|
||||
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.08 #
|
||||
##############################################################################
|
||||
# NATS-Bench: Benchmarking NAS algorithms for Architecture Topology and Size #
|
||||
#####################################################################################
|
||||
# The history of benchmark files (the name is NATS-tss-[version]-[md5].pickle.pbz2) #
|
||||
# [2020.08.31] #
|
||||
#####################################################################################
|
||||
import os, copy, random, numpy as np
|
||||
from pathlib import Path
|
||||
from typing import List, Text, Union, Dict, Optional
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
||||
from .api_utils import pickle_load
|
||||
from .api_utils import ArchResults
|
||||
from .api_utils import NASBenchMetaAPI
|
||||
from .api_utils import remap_dataset_set_names
|
||||
|
||||
|
||||
ALL_BENCHMARK_FILES = ['NAS-Bench-201-v1_0-e61699.pth', 'NAS-Bench-201-v1_1-096897.pth']
|
||||
ALL_ARCHIVE_DIRS = ['NAS-Bench-201-v1_1-archive']
|
||||
PICKLE_EXT = 'pickle.pbz2'
|
||||
ALL_BASE_NAMES = ['NATS-tss-v1_0-xxxxx']
|
||||
|
||||
|
||||
def print_information(information, extra_info=None, show=False):
|
||||
@ -49,10 +52,11 @@ This is the class for the API of topology search space in NATS-Bench.
|
||||
class NATStopology(NASBenchMetaAPI):
|
||||
|
||||
""" The initialization function that takes the dataset file path (or a dict loaded from that path) as input. """
|
||||
def __init__(self, file_path_or_dict: Optional[Union[Text, Dict]]=None,
|
||||
verbose: bool=True):
|
||||
def __init__(self, file_path_or_dict: Optional[Union[Text, Dict]]=None, fast_mode: bool=False, verbose: bool=True):
|
||||
self.filename = None
|
||||
self._search_space_name = 'topology'
|
||||
self._fast_mode = fast_mode
|
||||
self._archive_dir = None
|
||||
self.reset_time()
|
||||
if file_path_or_dict is None:
|
||||
file_path_or_dict = os.path.join(os.environ['TORCH_HOME'], ALL_BENCHMARK_FILES[-1])
|
||||
|
Loading…
Reference in New Issue
Block a user