You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 1.4 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """
  2. NAS algorithms
  3. """
  4. import importlib
  5. import os
  6. from .base import BaseNAS
  7. NAS_ALGO_DICT = {}
  8. def register_nas_algo(name):
  9. def register_nas_algo_cls(cls):
  10. if name in NAS_ALGO_DICT:
  11. raise ValueError(
  12. "Cannot register duplicate NAS algorithm ({})".format(name)
  13. )
  14. if not issubclass(cls, BaseNAS):
  15. raise ValueError(
  16. "Model ({}: {}) must extend NAS algorithm".format(name, cls.__name__)
  17. )
  18. NAS_ALGO_DICT[name] = cls
  19. return cls
  20. return register_nas_algo_cls
  21. from .darts import Darts
  22. from .enas import Enas
  23. from .random_search import RandomSearch
  24. from .rl import RL, GraphNasRL
  25. from ..backend import *
  26. if not is_dgl():
  27. from .gasso import Gasso
  28. from .spos import Spos
  29. def build_nas_algo_from_name(name: str) -> BaseNAS:
  30. """
  31. Parameters
  32. ----------
  33. name: ``str``
  34. the name of nas algorithm.
  35. Returns
  36. -------
  37. BaseNAS:
  38. the NAS algorithm built using default parameters
  39. Raises
  40. ------
  41. AssertionError
  42. If an invalid name is passed in
  43. """
  44. assert name in NAS_ALGO_DICT, "HPO module do not have name " + name
  45. return NAS_ALGO_DICT[name]()
  46. __all__ = ["BaseNAS", "Darts", "Enas", "RandomSearch", "RL", "GraphNasRL","Spos"]
  47. if not is_dgl():
  48. __all__.append("Gasso")