NNI model space hub contains a curated list of well-known NAS search spaces, along with a number of famous model space building blocks. Consider reading this document or try the models / spaces provided in the hub if you intend to:
1. Use a pre-defined model space as a starting point for your model development.
2. Try the state-of-the-art searched architecture along with its associated weights in your own task.
3. Learn the performance of NNI's built-in NAS search strategies on some well-recognized model spaces.
4. Build and test your NAS algorithm on the space hub and fairly compare them with other baselines.
List of supported model spaces
------------------------------
The model spaces provided so far are all built for image classification tasks, though they can serve as backbones for downstream tasks.
One way to use the model space is to directly leverage the searched results. Note that some of them have already been well-known neural networks and widely used.
.. code-block:: python
from nni.retiarii.hub.pytorch import MobileNetV3Space
# Load one of the searched results from MobileNetV3 search space.
In the example above, ``MobileNetV3Space`` can be replaced with any model spaces in the hub, and ``mobilenetv3-small-100`` can be any model alias listed below.
1. The metrics listed above are obtained by evaluating the checkpoints provided by the original author and converted to NNI NAS format with `these scripts <https://github.com/ultmaster/spacehub-conversion>`__. Do note that some metrics can be higher / lower than the original report, because there could be subtle differences between data preprocessing, operation implementation (e.g., 3rd-party hswish vs ``nn.Hardswish``), or even library versions we are using. But most of these errors are acceptable (~0.1%).
2. The default metric for ImageNet and CIFAR-10 is top-1 accuracy.
3. Refer to `timm <https://github.com/rwightman/pytorch-image-models>`__ for the evaluation configurations.
.. todos: measure latencies and flops, reproduce training.
Searching within model spaces
-----------------------------
To search within a model space for a new architecture on a particular dataset,
users need to create model space, search strategy, and evaluator following the :doc:`standard procedures </tutorials/hello_nas>`.
Here is a short sample code snippet for reference.
.. code-block:: python
# Create the model space
from nni.retiarii.hub.pytorch import MobileNetV3Space
model_space = MobileNetV3Space()
# Pick a search strategy
from nni.retiarii.strategy import Evolution
strategy = Evolution() # It can be any strategy, including one-shot strategies.
# Define an evaluator
from nni.retiarii.evaluator.pytorch import Classification