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