Skip to content

Commit

Permalink
hyperparameter search
Browse files Browse the repository at this point in the history
  • Loading branch information
ShokouhZolfaghari committed Sep 3, 2024
1 parent 78c60e2 commit db3d529
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 67 deletions.
12 changes: 6 additions & 6 deletions hpsearch/config/DBLP_v1_GCN_hp_tuning.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"oracle": {
"class": "hpsearch.oracle.torch.OracleTorch",
"parameters": {
"epochs": 500,
"epochs": 200,
"batch_size": 64,
"optimizer": {
"class": "torch.optim.AdamW",
"parameters": {
"lr":0.005597827355896938,
"weight_decay":0.022451620056299467
"lr":0.006,
"weight_decay":0.004
}
},
"loss_fn": {
Expand All @@ -29,10 +29,10 @@
"model": {
"class": "src.oracle.nn.gcn.DownstreamGCN",
"parameters": {
"num_conv_layers":5,
"num_conv_layers":6,
"num_dense_layers":9,
"conv_booster":2,
"linear_decay":0.3211868888719398
"conv_booster":5,
"linear_decay":0.4
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions hpsearch/hp_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def optimize(self):

#Create a study object and optimize the objective function
study = optuna.create_study(direction='maximize')

try:
study.optimize(self.objective, n_trials=self.n_trials, show_progress_bar=True)
except KeyboardInterrupt:
Expand All @@ -38,11 +38,11 @@ def objective(self, trial):

#Suggest values of the hyperparameters using a trial object.
#batch_size = trial.trial.suggest_categorical('batch_size', [32, 64])
learning_rate = trial.suggest_float('lr', 1e-5, 1e-1)
weight_decay = trial.suggest_float('weight_decay', 1e-5, 1e-1)
num_conv_layers = trial.suggest_int('num_conv_layers', 1, 10)
num_dense_layers = trial.suggest_int('num_dense_layers', 1, 10)
conv_booster = trial.suggest_int('conv_booster', 1, 10)
learning_rate = trial.suggest_float('lr', 1e-03, 1e-01)
weight_decay = trial.suggest_float('weight_decay', 1e-05, 1e-01)
num_conv_layers = trial.suggest_int('num_conv_layers', 1, 5)
num_dense_layers = trial.suggest_int('num_dense_layers', 1, 5)
conv_booster = trial.suggest_int('conv_booster', 1, 5)
linear_decay = trial.suggest_float('linear_decay', 0, 2)

self.oracle_config['parameters']['optimizer']['parameters']['lr'] = learning_rate
Expand Down
228 changes: 173 additions & 55 deletions notebooks/dataset_generator.ipynb

Large diffs are not rendered by default.

0 comments on commit db3d529

Please sign in to comment.