2121class HyperLightning :
2222 """
2323 Hyperparameter Tuning for Lightning.
24+
25+ Args:
26+ seed (int): seed for the random number generator. See Numpy Random Sampling.
27+ log_level (int): log level for the logger.
28+
29+ Attributes:
30+ seed (int): seed for the random number generator.
31+ rng (Generator): random number generator.
32+ fun_control (dict): dictionary containing control parameters for the hyperparameter tuning.
33+ log_level (int): log level for the logger.
34+
35+ Examples:
36+ >>> hyper_light = HyperLight(seed=126, log_level=50)
37+ >>> print(hyper_light.seed)
38+ 126
2439 """
2540
2641 def __init__ (self , seed : int = 126 , log_level : int = 50 ) -> None :
@@ -90,11 +105,33 @@ def fun(self, X: np.ndarray, fun_control: dict = None) -> np.ndarray:
90105 array containing the evaluation results.
91106
92107 Examples:
93- >>> hyper_light = HyperLight(seed=126, log_level=50)
94- X = np.array([[1, 2], [3, 4]])
95- fun_control = {"weights": np.array([1, 0, 0])}
96- hyper_light.fun(X, fun_control)
97- array([nan, nan])
108+ >>> MAX_TIME = 1
109+ INIT_SIZE = 5
110+ WORKERS = 0
111+ PREFIX="TEST"
112+ from spotPython.utils.init import fun_control_init
113+ from spotPython.utils.file import get_experiment_name, get_spot_tensorboard_path
114+ from spotPython.utils.device import getDevice
115+ experiment_name = get_experiment_name(prefix=PREFIX)
116+ fun_control = fun_control_init(
117+ spot_tensorboard_path=get_spot_tensorboard_path(experiment_name),
118+ num_workers=WORKERS,
119+ device=getDevice(),
120+ _L_in=3,
121+ _L_out=10,
122+ TENSORBOARD_CLEAN=True)
123+ from spotPython.light.cnn.googlenet import GoogleNet
124+ from spotPython.data.lightning_hyper_dict import LightningHyperDict
125+ from spotPython.hyperparameters.values import add_core_model_to_fun_control
126+ add_core_model_to_fun_control(core_model=GoogleNet,
127+ fun_control=fun_control,
128+ hyper_dict= LightningHyperDict)
129+ from spotPython.hyperparameters.values import get_default_hyperparameters_as_array
130+ X_start = get_default_hyperparameters_as_array(fun_control)
131+ from spotPython.fun.hyperlightning import HyperLightning
132+ hyper_light = HyperLightning(seed=126, log_level=50)
133+ hyper_light.fun(X=X_start, fun_control=fun_control)
134+
98135 """
99136 z_res = np .array ([], dtype = float )
100137 if fun_control is not None :
@@ -104,6 +141,8 @@ def fun(self, X: np.ndarray, fun_control: dict = None) -> np.ndarray:
104141 # type information and transformations are considered in generate_one_config_from_var_dict:
105142 for config in generate_one_config_from_var_dict (var_dict , self .fun_control ):
106143 logger .debug (f"\n config: { config } " )
144+ print (f"\n core_model: { fun_control ['core_model' ]} " )
145+ print (f"config: { config } " )
107146 # extract parameters like epochs, batch_size, lr, etc. from config
108147 # config_id = generate_config_id(config)
109148 try :
0 commit comments