DEHB#
DEHBBase(cs=None, f=None, dimensions=None, mutation_factor=None, crossover_prob=None, strategy=None, min_fidelity=None, max_fidelity=None, eta=None, min_clip=None, max_clip=None, seed=None, boundary_fix_type='random', max_age=np.inf, resume=False, **kwargs)
#
Source code in src/dehb/optimizers/dehb.py
get_incumbents()
#
Retrieve current incumbent configuration and score.
RETURNS | DESCRIPTION |
---|---|
Tuple[Union[dict, Configuration], float]
|
Tuple containing incumbent configuration and score. |
Source code in src/dehb/optimizers/dehb.py
DEHB(cs=None, f=None, dimensions=None, mutation_factor=0.5, crossover_prob=0.5, strategy='rand1_bin', min_fidelity=None, max_fidelity=None, eta=3, min_clip=None, max_clip=None, seed=None, configspace=True, boundary_fix_type='random', max_age=np.inf, n_workers=None, client=None, async_strategy='immediate', save_freq='incumbent', resume=False, **kwargs)
#
Bases: DEHBBase
Source code in src/dehb/optimizers/dehb.py
__getstate__()
#
Allows the object to picklable while having Dask client as a class attribute.
Source code in src/dehb/optimizers/dehb.py
__del__()
#
vector_to_configspace(config)
#
Converts numpy representation to Configuration
.
PARAMETER | DESCRIPTION |
---|---|
config |
Configuration to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Configuration
|
ConfigSpace.Configuration: Converted configuration |
Source code in src/dehb/optimizers/dehb.py
configspace_to_vector(config)
#
Converts Configuration
to numpy array.
PARAMETER | DESCRIPTION |
---|---|
config |
Configuration to convert
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
array
|
np.array: Converted configuration |
Source code in src/dehb/optimizers/dehb.py
ask(n_configs=1)
#
Get the next configuration to run from the optimizer.
The retrieved configuration can then be evaluated by the user.
After evaluation use tell
to report the results back to the optimizer.
For more information, please refer to the description of tell
.
PARAMETER | DESCRIPTION |
---|---|
n_configs |
Number of configs to ask for. Defaults to 1.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[dict, List[dict]]
|
dict or list of dict: Job info(s) of next configuration to evaluate. |
Source code in src/dehb/optimizers/dehb.py
save()
#
Saves the current incumbent, history and state to disk.
Source code in src/dehb/optimizers/dehb.py
tell(job_info, result, replay=False)
#
Feed a result back to the optimizer.
In order to correctly interpret the results, the job_info
dict, retrieved by ask
,
has to be given. Moreover, the result
dict has to contain the keys fitness
and cost
.
fitness
resembles the objective you are trying to optimize, e.g. validation loss.
cost
resembles the computational cost for computing the result, e.g. the wallclock time
for training and validating a neural network to achieve the validation loss specified in
fitness
. It is also possible to add the field info
to the result
in order to store
additional, user-specific information.
User-specific information info
Please note, that we only support types, that are serializable by pandas
. If
non-serializable types are used, DEHB will not be able to save the history.
If you want to be on the safe side, please use built-in python types.
PARAMETER | DESCRIPTION |
---|---|
job_info |
Job info returned by ask().
TYPE:
|
result |
Result dictionary with mandatory keys
TYPE:
|
Source code in src/dehb/optimizers/dehb.py
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
run(fevals=None, brackets=None, total_cost=None, single_node_with_gpus=False, **kwargs)
#
Main interface to run optimization by DEHB.
This function waits on workers and if a worker is free, asks for a configuration and a fidelity to evaluate on and submits it to the worker. In each loop, it checks if a job is complete, fetches the results, carries the necessary processing of it asynchronously to the worker computations.
The duration of the DEHB run can be controlled by specifying one of 3 parameters. If more
than one are specified, DEHB selects only one in the priority order (high to low):
1) Number of function evaluations (fevals)
2) Number of Successive Halving brackets run under Hyperband (brackets)
3) Total computational cost (in seconds) aggregated by all function evaluations (total_cost)
Using tell
under the hood.
Please note, that run
uses tell
under the hood, therefore please have a
look at the documentation of tell
for more information e.g. about the result format.
Adjusting verbosity
The verbosity of DEHB logs can be adjusted via adding the log_level
parameter to DEHBs
initialization. As we use loguru, the logging levels can be found on their website.
PARAMETER | DESCRIPTION |
---|---|
fevals |
Number of functions evaluations to run. Defaults to None.
TYPE:
|
brackets |
Number of brackets to run. Defaults to None.
TYPE:
|
total_cost |
Wallclock budget in seconds. Defaults to None.
TYPE:
|
single_node_with_gpus |
Workers get assigned different GPUs. Default to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[array, array, array]
|
Trajectory, runtime and optimization history. |
Source code in src/dehb/optimizers/dehb.py
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 |
|