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.2 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 .spos import Spos
  26. def build_nas_algo_from_name(name: str) -> BaseNAS:
  27. """
  28. Parameters
  29. ----------
  30. name: ``str``
  31. the name of nas algorithm.
  32. Returns
  33. -------
  34. BaseNAS:
  35. the NAS algorithm built using default parameters
  36. Raises
  37. ------
  38. AssertionError
  39. If an invalid name is passed in
  40. """
  41. assert name in NAS_ALGO_DICT, "HPO module do not have name " + name
  42. return NAS_ALGO_DICT[name]()
  43. __all__ = ["BaseNAS", "Darts", "Enas", "RandomSearch", "RL", "GraphNasRL","Spos"]