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

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