automl / NASLib

NASLib is a Neural Architecture Search (NAS) library for facilitating NAS research for the community by providing interfaces to several state-of-the-art NAS search spaces and optimizers.
Apache License 2.0
514 stars 118 forks source link

How to parse any arch in NAS-Bench-101 as pytorch class to train. #121

Open NLGithubWP opened 2 years ago

NLGithubWP commented 2 years ago

Hi, I'm trying to sample few architectures from NAS-Bench-101, and then query the socre, and also get the torch-model according to the architecutre.

I wanna use the model to do some customer training or testing.

In core/graph.py, it shows we should us the following code to parse the model to pytorch module

    **Use as pytorch module**
    If you want to learn the weights of the operations or any
    other parameters of the graph you have to parse it first.
    >>> graph = getFancySearchSpace()
    >>> graph.parse()
    >>> logits = graph(data)
    >>> optimizer.min(loss(logits, target))

But the graph.parse() will fail if i use NasBench101SearchSpace as graph instance ,