Home

Awesome

BANANAS

Note: our naszilla/bananas repo has been extended and renamed to naszilla/naszilla, and this repo is deprecated and not maintained. Please use naszilla/naszilla, which has more functionality.

BANANAS: Bayesian Optimization with Neural Architectures for Neural Architecture Search
Colin White, Willie Neiswanger, and Yash Savani.
arXiv:1910.11858.

A new method for neural architecture search

BANANAS is a neural architecture search (NAS) algorithm which uses Bayesian optimization with a meta neural network to predict the validation accuracy of neural architectures. We use a path-based encoding scheme to featurize the neural architectures that are used to train the neural network model. After training on just 200 architectures, we are able to predict the validation accuracy of new architectures to within one percent on average. The full NAS algorithm beats the state of the art on the NASBench and the DARTS search spaces. On the NASBench search space, BANANAS is over 100x more efficient than random search, and 3.8x more efficent than the next-best algorithm we tried. On the DARTS search space, BANANAS finds an architecture with a test error of 2.57%.

<p align="center"> <img src="img/bananas_fig.png" alt="bananas_fig" width="70%"> </p>

Requirements

If you run experiments on DARTS, you will need our fork of the darts repo:

Train a meta neural network with a notebook on the NASBench dataset

<p align="center"> <img src="img/metann_adj_train.png" alt="bananas_fig" width="24%"> <img src="img/metann_adj_test.png" alt="bananas_fig" width="24%"> <img src="img/metann_path_train.png" alt="bananas_fig" width="24%"> <img src="img/metann_path_test.png" alt="bananas_fig" width="24%"> </p>

Evaluate pretrained BANANAS architecture

The best architecture found by BANANAS on the DARTS search space achieved 2.57% test error. To evaluate our pretrained neural architecture, download the weights bananas.pt and put it inside the folder <path-to-darts>/cnn

cd <path-to-darts>/cnn; python test.py --model_path bananas.pt

The error on the test set should be 2.57%. This can be run on a CPU or GPU, but it will be faster on a GPU.

<p align="center"> <img src="img/bananas_normal.png" alt="bananas_normal" width="42%"> <img src="img/bananas_reduction.png" alt="bananas_reduction" width="47%"> </p> <p align="center"> The best neural architecture found by BANANAS on CIFAR-10. Convolutional cell (left), and reduction cell (right). </p>

Train BANANAS architecture

Train the best architecture found by BANANAS.

cd <path-to-darts>/cnn; python train.py --auxiliary --cutout

This will train the architecture from scratch, which takes about 34 hours on an NVIDIA V100 GPU. The final test error should be 2.59%. Setting the random seed to 4 by adding --seed 4 will result in a test error of 2.57%. We report the random seeds and hardware used in Table 2 of our paper here.

Run BANANAS on the NASBench search space

To run BANANAS on NASBench, download nasbench_only108.tfrecord and place it in the top level folder of this repo.

python run_experiments_sequential.py

This will test the nasbench algorithm against several other NAS algorithms on the NASBench search space. To customize your experiment, open params.py. Here, you can change the hyperparameters and the algorithms to run. To run experiments with NAS-Bench-201, download NAS-Bench-201-v1_0-e61699.pth and place it in the top level folder of this repo. Choose between cifar10, cifar100, and imagenet. For example,

python run_experiments_sequential.py --search_space nasbench_201_cifar10
<p align="center"> <img src="img/nasbench_plot.png" alt="nasbench_plot" width="70%"> </p>

Run BANANAS on the DARTS search space

We highly recommend using multiple GPUs to run BANANAS on the DARTS search space. You can run BANANAS in parallel on GCP using the shell script:

run_experiments_parallel.sh

Contributions

We welcome community contributions to this repo!

Citation

Please cite our paper if you use code from this repo:

@inproceedings{white2019bananas,
  title={BANANAS: Bayesian Optimization with Neural Architectures for Neural Architecture Search},
  author={White, Colin and Neiswanger, Willie and Savani, Yash},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  year={2021}
}