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.

enums.py 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Enums."""
  16. import enum
  17. class BaseEnum(enum.Enum):
  18. """Base enum."""
  19. @classmethod
  20. def list_members(cls):
  21. """List all members."""
  22. return [member.value for member in cls]
  23. class ReasonCode(BaseEnum):
  24. """Reason code for calculating importance."""
  25. NOT_ALL_NUMBERS = 1
  26. SAMPLES_NOT_ENOUGH = 2
  27. CORRELATION_NAN = 3
  28. class AcquisitionFunctionEnum(BaseEnum):
  29. """Enum for acquisition function method."""
  30. # Upper confidence bound
  31. UCB = 'ucb'
  32. # Probability of improvement
  33. PI = 'pi'
  34. # Expected improvement
  35. EI = 'ei'
  36. class TuneMethod(BaseEnum):
  37. """Enum for tuning method."""
  38. # Gaussian process regressor
  39. GP = 'gp'
  40. class GPSupportArgs(BaseEnum):
  41. METHOD = 'method'
  42. class HyperParamKey(BaseEnum):
  43. """Config keys for hyper parameters."""
  44. BOUND = 'bounds'
  45. CHOICE = 'choice'
  46. DECIMAL = 'decimal'
  47. TYPE = 'type'
  48. SOURCE = 'source'
  49. class HyperParamType(BaseEnum):
  50. """Config keys for hyper parameters."""
  51. INT = 'int'
  52. FLOAT = 'float'
  53. class TargetKey(BaseEnum):
  54. """Config keys for target."""
  55. GROUP = 'group'
  56. NAME = 'name'
  57. GOAL = 'goal'
  58. class TargetGoal(BaseEnum):
  59. """Goal for target."""
  60. MAXIMUM = 'maximize'
  61. MINIMUM = 'minimize'
  62. class HyperParamSource(BaseEnum):
  63. SYSTEM_DEFINED = 'system_defined'
  64. USER_DEFINED = 'user_defined'
  65. class TargetGroup(BaseEnum):
  66. SYSTEM_DEFINED = 'system_defined'
  67. METRIC = 'metric'
  68. class TunableSystemDefinedParams(BaseEnum):
  69. """Tunable metadata keys of lineage collection."""
  70. BATCH_SIZE = 'batch_size'
  71. EPOCH = 'epoch'
  72. LEARNING_RATE = 'learning_rate'
  73. class SystemDefinedTargets(BaseEnum):
  74. """System defined targets"""
  75. LOSS = 'loss'