diff --git a/Experiments/configurations/eiv_california.json b/Experiments/configurations/eiv_california.json index 29a71622d99299d2c7ccde4f148b560de52418ee..4786d5b03d3445dda8a567d74e4f1427390bed2a 100644 --- a/Experiments/configurations/eiv_california.json +++ b/Experiments/configurations/eiv_california.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.1, "lr_update": 20, - "epoch_offset": 10, + "std_y_update_points": 10, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_concrete.json b/Experiments/configurations/eiv_concrete.json index 11121c144b429ad2f970aa815f2a4e7fed8a893a..0e234346f6dda090daacb9aebf33f8c3f666081c 100644 --- a/Experiments/configurations/eiv_concrete.json +++ b/Experiments/configurations/eiv_concrete.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 10, + "std_y_update_points": 10, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_energy.json b/Experiments/configurations/eiv_energy.json index bca6774dd7b4ce71ca78b487246d6a5e7f4b76f3..f13ab1b52417aa7ed20c4db9d75a0c653ff0b321 100644 --- a/Experiments/configurations/eiv_energy.json +++ b/Experiments/configurations/eiv_energy.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 100, - "epoch_offset": 100, + "std_y_update_points": 100, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_kin8nm.json b/Experiments/configurations/eiv_kin8nm.json index fa3718a096e417c2ab456a8589009d0052ae6670..df2e4bafbee99aca95dcd36f8f67097d3a6ce3b5 100644 --- a/Experiments/configurations/eiv_kin8nm.json +++ b/Experiments/configurations/eiv_kin8nm.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 19, + "std_y_update_points": 19, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_msd.json b/Experiments/configurations/eiv_msd.json index 1c2527630dac6172c9271ee230b5c34a2abfd71f..a738f2e8bf034e173f60b17e5cd6d2f7d6fdb856 100644 --- a/Experiments/configurations/eiv_msd.json +++ b/Experiments/configurations/eiv_msd.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 4, - "epoch_offset": 4, + "std_y_update_points": 4, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_naval.json b/Experiments/configurations/eiv_naval.json index 3358831d627188d5c2b93ceaa748b77de893c23d..092f4f822abf0e9c677affa8ae275e46309435b8 100644 --- a/Experiments/configurations/eiv_naval.json +++ b/Experiments/configurations/eiv_naval.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 20, + "std_y_update_points": 20, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_power.json b/Experiments/configurations/eiv_power.json index 842f6e2662bef07696de1eb5f041e677b586dcd6..ab5649f61de1ea2214249b8a07e25cd5b2adea9e 100644 --- a/Experiments/configurations/eiv_power.json +++ b/Experiments/configurations/eiv_power.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 10, - "epoch_offset": 15, + "std_y_update_points": 15, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_protein.json b/Experiments/configurations/eiv_protein.json index 97f5946d431d04bc83c71904846152160fa0c7d7..9623799e3d8b85b2f568987afb4d406fbb7fe45c 100644 --- a/Experiments/configurations/eiv_protein.json +++ b/Experiments/configurations/eiv_protein.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 10, - "epoch_offset": 10, + "std_y_update_points": 10, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_wine.json b/Experiments/configurations/eiv_wine.json index 0b40a61272719cee6afc839f171103c54a830af8..f0beaf490846c2281a477f627f05c98b18cfa7f3 100644 --- a/Experiments/configurations/eiv_wine.json +++ b/Experiments/configurations/eiv_wine.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 30, - "epoch_offset": 50, + "std_y_update_points": 50, "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/eiv_yacht.json b/Experiments/configurations/eiv_yacht.json index c668113462816474eca51186853bbc241ca3160d..f95841b1a8074294a5d1ba0b921c8deee0dd5d4f 100644 --- a/Experiments/configurations/eiv_yacht.json +++ b/Experiments/configurations/eiv_yacht.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 200, - "epoch_offset": 20, + "std_y_update_points": [20,20], "eiv_prediction_number_of_draws": 100, "eiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_california.json b/Experiments/configurations/noneiv_california.json index 5005b43d8272c22893903a8a6c7494edeed4e554..7c8f4683aaf7bd6411bb6eaf336c85b39dbe8a15 100644 --- a/Experiments/configurations/noneiv_california.json +++ b/Experiments/configurations/noneiv_california.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.1, "lr_update": 20, - "epoch_offset": 0 , + "std_y_update_points": 0 , "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_concrete.json b/Experiments/configurations/noneiv_concrete.json index 66552b7193675eda193479ff9909494fc2bc2133..15e28c53a67064987c267f932733a09d00698c43 100644 --- a/Experiments/configurations/noneiv_concrete.json +++ b/Experiments/configurations/noneiv_concrete.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 10, + "std_y_update_points": 10, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_energy.json b/Experiments/configurations/noneiv_energy.json index 74eb45c721793e94f0efbb4d67a3f4acaa05e8da..18c068ea7a9cb96f1075a522ae3f3ad6552bacac 100644 --- a/Experiments/configurations/noneiv_energy.json +++ b/Experiments/configurations/noneiv_energy.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 100, - "epoch_offset": 100, + "std_y_update_points": 100, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_kin8nm.json b/Experiments/configurations/noneiv_kin8nm.json index 22615f61b00cf2b06c6e5fbc0051f3c86e8f92cb..8ecf817149b1a37dd9a4ab5c44fd2700795fbcde 100644 --- a/Experiments/configurations/noneiv_kin8nm.json +++ b/Experiments/configurations/noneiv_kin8nm.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 19, + "std_y_update_points": 19, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_msd.json b/Experiments/configurations/noneiv_msd.json index 1c4f338fe3152c6a21d66cff05376efcbf88f148..a0e2f73beb63e165c7da5266b774f227e90310c1 100644 --- a/Experiments/configurations/noneiv_msd.json +++ b/Experiments/configurations/noneiv_msd.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 4, - "epoch_offset": 4, + "std_y_update_points": 4, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_naval.json b/Experiments/configurations/noneiv_naval.json index 5dea6c49692e193dc25818ae83c6f467860a1520..2da83b73101d1a5a957f9773053b9610b0cb8aff 100644 --- a/Experiments/configurations/noneiv_naval.json +++ b/Experiments/configurations/noneiv_naval.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 20, - "epoch_offset": 20, + "std_y_update_points": 20, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_power.json b/Experiments/configurations/noneiv_power.json index 6e524e6c4f684f9c0affc983f3d2d5a7e4597248..48aac9dcf4cc208095142760d7bf286c2589b22b 100644 --- a/Experiments/configurations/noneiv_power.json +++ b/Experiments/configurations/noneiv_power.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 10, - "epoch_offset": 15, + "std_y_update_points": 15, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_protein.json b/Experiments/configurations/noneiv_protein.json index 1edd04fa1d28b8634080beec1865d30b6f854153..454deaef823c1a25c03588c4f430b5d0f67e5e93 100644 --- a/Experiments/configurations/noneiv_protein.json +++ b/Experiments/configurations/noneiv_protein.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 10, - "epoch_offset": 10, + "std_y_update_points": 10, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_wine.json b/Experiments/configurations/noneiv_wine.json index 717fb33c371b6d3743da58c4489ed96bd3e62ea6..ddd2199fae58e2dd62409d554f51983b5bd1ef02 100644 --- a/Experiments/configurations/noneiv_wine.json +++ b/Experiments/configurations/noneiv_wine.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 30, - "epoch_offset": 50, + "std_y_update_points": 50, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/configurations/noneiv_yacht.json b/Experiments/configurations/noneiv_yacht.json index edb775cc550ec8b2ca8ed32a4962cb64eea20e65..1a899215fb9e1a69b036243805ccbec977d2dc7c 100644 --- a/Experiments/configurations/noneiv_yacht.json +++ b/Experiments/configurations/noneiv_yacht.json @@ -9,7 +9,7 @@ "report_point": 5, "p": 0.2, "lr_update": 200, - "epoch_offset": 20, + "std_y_update_points": 20, "noneiv_prediction_number_of_draws": 100, "noneiv_prediction_number_of_batches": 10, "init_std_y_list": [0.5], diff --git a/Experiments/train_eiv.py b/Experiments/train_eiv.py index 78f6d61d5f0af1d0e29de0f10f99275db40f42c4..bb7c900e20b0e749391eb5b0587238bbade34007 100644 --- a/Experiments/train_eiv.py +++ b/Experiments/train_eiv.py @@ -40,10 +40,11 @@ report_point = conf_dict["report_point"] p = conf_dict["p"] lr_update = conf_dict["lr_update"] # offset before updating sigma_y after each epoch -epoch_offset = conf_dict["epoch_offset"] +std_y_update_points = conf_dict["std_y_update_points"] # will be used to predict the RMSE and update sigma_y accordingly eiv_prediction_number_of_draws = conf_dict["eiv_prediction_number_of_draws"] -eiv_prediction_number_of_batches = conf_dict["eiv_prediction_number_of_batches"] +eiv_prediction_number_of_batches = \ + conf_dict["eiv_prediction_number_of_batches"] init_std_y_list = conf_dict["init_std_y_list"] fixed_std_x = conf_dict['fixed_std_x'] gamma = conf_dict["gamma"] @@ -54,7 +55,8 @@ print(f"Training on {long_dataname} data") try: gpu_number = conf_dict["gpu_number"] - device = torch.device(f'cuda:{gpu_number}' if torch.cuda.is_available() else 'cpu') + device = torch.device(f'cuda:{gpu_number}' if torch.cuda.is_available() + else 'cpu') except KeyError: device = torch.device('cpu') @@ -65,7 +67,7 @@ seed_list = range(seed_range[0], seed_range[1]) def set_seeds(seed): torch.backends.cudnn.benchmark = False - np.random.seed(seed) + np.random.seed(seed) random.seed(seed) torch.manual_seed(seed) @@ -88,7 +90,22 @@ class UpdatedTrainEpoch(train_and_store.TrainEpoch): """ Overwrites the corresponding method """ - if epoch >= epoch_offset: + def update_std_y(epoch_number): + """ + Check whether to update std_y according to `epoch_number` and + `std_y_update_points`. If the later is an integer, after all epochs + greater than this number an update will be made (i.e. `True` will + be returned). If it is a list, only `epoch_number` greater than + `std_y_update_points[0]` that divide `std_y_update_points[1]` will + result in a True. + """ + if type(std_y_update_points) is int: + return epoch >= std_y_update_points + else: + assert type(std_y_update_points) is list + return epoch_number >= std_y_update_points[0]\ + and epoch_number % std_y_update_points[1] == 0 + if update_std_y(epoch): pred_collection = [] y_collection = [] for i, (x,y) in enumerate(self.train_dataloader): diff --git a/Experiments/train_noneiv.py b/Experiments/train_noneiv.py index e63dbf233062d7ee47465cd5cd50f5708271cd68..8b89296b38ce140bf95a338d266bc1075a89bd3d 100644 --- a/Experiments/train_noneiv.py +++ b/Experiments/train_noneiv.py @@ -40,10 +40,11 @@ report_point = conf_dict["report_point"] p = conf_dict["p"] lr_update = conf_dict["lr_update"] # offset before updating sigma_y after each epoch -epoch_offset = conf_dict["epoch_offset"] +std_y_update_points = conf_dict["std_y_update_points"] # will be used to predict the RMSE and update sigma_y accordingly noneiv_prediction_number_of_draws = conf_dict["noneiv_prediction_number_of_draws"] -noneiv_prediction_number_of_batches = conf_dict["noneiv_prediction_number_of_batches"] +noneiv_prediction_number_of_batches = \ + conf_dict["noneiv_prediction_number_of_batches"] init_std_y_list = conf_dict["init_std_y_list"] gamma = conf_dict["gamma"] hidden_layers = conf_dict["hidden_layers"] @@ -53,7 +54,8 @@ print(f"Training on {long_dataname} data") try: gpu_number = conf_dict["gpu_number"] - device = torch.device(f'cuda:{gpu_number}' if torch.cuda.is_available() else 'cpu') + device = torch.device(f'cuda:{gpu_number}' if torch.cuda.is_available() + else 'cpu') except KeyError: device = torch.device('cpu') @@ -87,11 +89,26 @@ class UpdatedTrainEpoch(train_and_store.TrainEpoch): """ Overwrites the corresponding method """ - if epoch >= epoch_offset: + def update_std_y(epoch_number): + """ + Check whether to update std_y according to `epoch_number` and + `std_y_update_points`. If the later is an integer, after all epochs + greater than this number an update will be made (i.e. `True` will + be returned). If it is a list, only `epoch_number` greater than + `std_y_update_points[0]` that divide `std_y_update_points[1]` will + result in a True. + """ + if type(std_y_update_points) is int: + return epoch >= std_y_update_points + else: + assert type(std_y_update_points) is list + return epoch_number >= std_y_update_points[0]\ + and epoch_number % std_y_update_points[1] == 0 + if update_std_y(epoch): pred_collection = [] y_collection = [] for i, (x,y) in enumerate(self.train_dataloader): - if i>= noneiv_prediction_number_of_batches: + if i >= noneiv_prediction_number_of_batches: break if len(y.shape) <= 1: y = y.view((-1,1))