Loading main.py +14 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ from src.evaluation import evaluate NUM_WORKERS = 0 if platform.system() == "Windows" else 6 CUDA_CAPABLE = torch.cuda.is_available() MAX_SECONDS_PER_TRIAL = 7200 if len(sys.argv) < 2 else int(sys.argv[1]) STORAGE_PATH = "results.log" if len(sys.argv) < 3 else sys.argv[2] ############################################################################### Loading Loading @@ -54,7 +55,19 @@ def objective(trial): ############################################################################### if platform.system() != "Windows": storage = optuna.storages.JournalStorage( optuna.storages.JournalFileStorage(STORAGE_PATH), ) else: lock_obj = optuna.storages.JournalFileOpenLock(STORAGE_PATH) storage = optuna.storages.JournalStorage( optuna.storages.JournalFileStorage(STORAGE_PATH, lock_obj=lock_obj), ) if __name__ == '__main__': study = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler()) study = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler(), storage=storage) study.optimize(objective) src/builders.py +1 −0 Original line number Diff line number Diff line Loading @@ -166,4 +166,5 @@ def build_l_layers(trial: Trial, first_input_size: int) -> nn.Sequential: l_layers.append(dropout_layer) return nn.Sequential(*l_layers) src/suggestions.py +11 −11 Original line number Diff line number Diff line Loading @@ -12,20 +12,20 @@ def suggest_params_general(trial: Trial) -> None: """ # Parameters of input trial.suggest_categorical("input_size", [96, 112, 128]) trial.suggest_int("input_size", 96, 128, step=16) # Parameters of learning trial.suggest_int("epochs", 6, 64) trial.suggest_categorical("batch_size", [4, 12, 16, 24, 32, 40, 48, 64]) trial.suggest_int("epochs", 6, 72) trial.suggest_int("batch_size", 4, 80, step=4) # Parameters of loss function trial.suggest_float("margin", 1, 3) # Parameters of optimizer trial.suggest_float("lr", 1e-8, 0.0001) trial.suggest_float("weight_decay", 1e-7, 1e-2, log=True) trial.suggest_float("beta1", 0.85, 0.95) trial.suggest_float("beta2", 0.98, 0.999) trial.suggest_float("lr", 1e-5, 0.1) trial.suggest_float("weight_decay", 1e-6, 1e-2, log=True) trial.suggest_float("beta1", 0.65, 0.95) trial.suggest_float("beta2", 0.945, 0.999) # Parameters of the network itself trial.suggest_int("c_layers", 3, 5) Loading Loading @@ -155,13 +155,13 @@ def suggest_l_layers(trial: Trial) -> None: # Config for count of fully-connected layers if trial.params["l_layers"] == 3: outputs = [(256, 6144, 256), (128, 1536, 32), (2, 32, 2)] outputs = [(256, 4096, 256), (128, 1536, 32), (2, 32, 2)] elif trial.params["l_layers"] == 4: outputs = [(512, 8192, 256), (256, 2048, 64), (96, 768, 32), (2, 32, 2)] outputs = [(256, 6144, 256), (256, 2048, 64), (96, 768, 32), (2, 32, 2)] else: outputs = [(512, 8192, 256), (512, 3072, 128), (192, 896, 32), (96, 384, 16), (2, 32, 2)] outputs = [(256, 8192, 256), (256, 3072, 128), (128, 896, 32), (96, 384, 16), (2, 32, 2)] # Suggest each fully-connected layer for i in range(0, trial.params["l_layers"]): Loading Loading
main.py +14 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ from src.evaluation import evaluate NUM_WORKERS = 0 if platform.system() == "Windows" else 6 CUDA_CAPABLE = torch.cuda.is_available() MAX_SECONDS_PER_TRIAL = 7200 if len(sys.argv) < 2 else int(sys.argv[1]) STORAGE_PATH = "results.log" if len(sys.argv) < 3 else sys.argv[2] ############################################################################### Loading Loading @@ -54,7 +55,19 @@ def objective(trial): ############################################################################### if platform.system() != "Windows": storage = optuna.storages.JournalStorage( optuna.storages.JournalFileStorage(STORAGE_PATH), ) else: lock_obj = optuna.storages.JournalFileOpenLock(STORAGE_PATH) storage = optuna.storages.JournalStorage( optuna.storages.JournalFileStorage(STORAGE_PATH, lock_obj=lock_obj), ) if __name__ == '__main__': study = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler()) study = optuna.create_study(direction="maximize", sampler=optuna.samplers.TPESampler(), storage=storage) study.optimize(objective)
src/builders.py +1 −0 Original line number Diff line number Diff line Loading @@ -166,4 +166,5 @@ def build_l_layers(trial: Trial, first_input_size: int) -> nn.Sequential: l_layers.append(dropout_layer) return nn.Sequential(*l_layers)
src/suggestions.py +11 −11 Original line number Diff line number Diff line Loading @@ -12,20 +12,20 @@ def suggest_params_general(trial: Trial) -> None: """ # Parameters of input trial.suggest_categorical("input_size", [96, 112, 128]) trial.suggest_int("input_size", 96, 128, step=16) # Parameters of learning trial.suggest_int("epochs", 6, 64) trial.suggest_categorical("batch_size", [4, 12, 16, 24, 32, 40, 48, 64]) trial.suggest_int("epochs", 6, 72) trial.suggest_int("batch_size", 4, 80, step=4) # Parameters of loss function trial.suggest_float("margin", 1, 3) # Parameters of optimizer trial.suggest_float("lr", 1e-8, 0.0001) trial.suggest_float("weight_decay", 1e-7, 1e-2, log=True) trial.suggest_float("beta1", 0.85, 0.95) trial.suggest_float("beta2", 0.98, 0.999) trial.suggest_float("lr", 1e-5, 0.1) trial.suggest_float("weight_decay", 1e-6, 1e-2, log=True) trial.suggest_float("beta1", 0.65, 0.95) trial.suggest_float("beta2", 0.945, 0.999) # Parameters of the network itself trial.suggest_int("c_layers", 3, 5) Loading Loading @@ -155,13 +155,13 @@ def suggest_l_layers(trial: Trial) -> None: # Config for count of fully-connected layers if trial.params["l_layers"] == 3: outputs = [(256, 6144, 256), (128, 1536, 32), (2, 32, 2)] outputs = [(256, 4096, 256), (128, 1536, 32), (2, 32, 2)] elif trial.params["l_layers"] == 4: outputs = [(512, 8192, 256), (256, 2048, 64), (96, 768, 32), (2, 32, 2)] outputs = [(256, 6144, 256), (256, 2048, 64), (96, 768, 32), (2, 32, 2)] else: outputs = [(512, 8192, 256), (512, 3072, 128), (192, 896, 32), (96, 384, 16), (2, 32, 2)] outputs = [(256, 8192, 256), (256, 3072, 128), (128, 896, 32), (96, 384, 16), (2, 32, 2)] # Suggest each fully-connected layer for i in range(0, trial.params["l_layers"]): Loading