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.

selector.py 1.4 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from abc import ABC, abstractmethod
  2. class Selector(ABC):
  3. """
  4. choose the best model from a group of candidates.
  5. To implement a new selector, users need to implement:
  6. method: "fit"
  7. method: "__init__"
  8. super().__init__() must be called in __init__ method
  9. parameters:
  10. -----------
  11. candidates: candidates to be evaluated
  12. ##### Examples #####
  13. # class HPOSelector(Selector):
  14. # def __init__(self, *args, single_candidate=True):
  15. # super().__init__(single_candidate)
  16. # self.args = args
  17. # def fit(self):
  18. #
  19. # # only one candatite, function passed
  20. #
  21. # pass
  22. ###########
  23. """
  24. @abstractmethod
  25. def __init__(self, single_candidate=True):
  26. self.single_candidate = single_candidate
  27. self._valid()
  28. @abstractmethod
  29. def fit(self, candidates=None):
  30. """
  31. evaluate the candidates to select the best one.
  32. any optimization algos could be implement here.
  33. if the inputs has only one candidates, just return the candidate directly
  34. """
  35. raise NotImplementedError
  36. def _valid(self, ):
  37. if self.single_candidate:
  38. print("### single model, selecting finished ###")
  39. exit(0)

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能