From 9e3fe510ddbd5c3040c356b385f464267c5779fa Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Tue, 22 Aug 2023 14:28:30 -0700 Subject: [PATCH 1/4] Add method to generate predictor dataset Signed-off-by: Maciej Szankin --- generate_predictor_data.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 generate_predictor_data.py diff --git a/generate_predictor_data.py b/generate_predictor_data.py new file mode 100644 index 0000000..09548e2 --- /dev/null +++ b/generate_predictor_data.py @@ -0,0 +1,27 @@ +import csv +from dynast.supernetwork.supernetwork_registry import SUPERNET_ENCODING, SUPERNET_METRICS, SUPERNET_PARAMETERS + +if __name__ == '__main__': + supernet: str = 'ofa_resnet50' + results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_a100.csv' + save_to_path: str = '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_accuracy_a100_imagenet.csv' + seed: int = 42 + config_name: str = 'subnet' + objective_name: str = 'accuracy_top1' + names = ['subnet', 'date'] + SUPERNET_METRICS[supernet] + + supernet_manager = SUPERNET_ENCODING[supernet]( + param_dict=SUPERNET_PARAMETERS[supernet], seed=seed + ) + + df = supernet_manager.import_csv( + results_path, config=config_name, objective=objective_name, column_names=names + ) + + with open(save_to_path, 'w', newline='', encoding='utf-8') as file: + mywriter = csv.writer(file, delimiter=',', lineterminator='\n') + for index, row in df.iterrows(): + subnet = row['subnet'] + features = subnet['d'] + subnet['e'] + subnet['w'] + predictor_row = features + [row[objective_name]] + mywriter.writerow(predictor_row) From d3b8da1ff7fd911a69c4c3dbe6ecf704a22076cc Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Tue, 22 Aug 2023 14:30:07 -0700 Subject: [PATCH 2/4] Fix lint Signed-off-by: Maciej Szankin --- generate_predictor_data.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/generate_predictor_data.py b/generate_predictor_data.py index 09548e2..d677a43 100644 --- a/generate_predictor_data.py +++ b/generate_predictor_data.py @@ -1,22 +1,21 @@ import csv + from dynast.supernetwork.supernetwork_registry import SUPERNET_ENCODING, SUPERNET_METRICS, SUPERNET_PARAMETERS if __name__ == '__main__': supernet: str = 'ofa_resnet50' results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_a100.csv' - save_to_path: str = '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_accuracy_a100_imagenet.csv' + save_to_path: str = ( + '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_accuracy_a100_imagenet.csv' + ) seed: int = 42 config_name: str = 'subnet' objective_name: str = 'accuracy_top1' names = ['subnet', 'date'] + SUPERNET_METRICS[supernet] - supernet_manager = SUPERNET_ENCODING[supernet]( - param_dict=SUPERNET_PARAMETERS[supernet], seed=seed - ) + supernet_manager = SUPERNET_ENCODING[supernet](param_dict=SUPERNET_PARAMETERS[supernet], seed=seed) - df = supernet_manager.import_csv( - results_path, config=config_name, objective=objective_name, column_names=names - ) + df = supernet_manager.import_csv(results_path, config=config_name, objective=objective_name, column_names=names) with open(save_to_path, 'w', newline='', encoding='utf-8') as file: mywriter = csv.writer(file, delimiter=',', lineterminator='\n') From 0d6d6e5cd957056810e38b3cfaf0dbadd62c898e Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Wed, 23 Aug 2023 11:53:20 -0700 Subject: [PATCH 3/4] Update Signed-off-by: Maciej Szankin --- generate_predictor_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generate_predictor_data.py b/generate_predictor_data.py index d677a43..a837cbc 100644 --- a/generate_predictor_data.py +++ b/generate_predictor_data.py @@ -4,13 +4,13 @@ if __name__ == '__main__': supernet: str = 'ofa_resnet50' - results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_a100.csv' + results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_clx8280.csv' save_to_path: str = ( - '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_accuracy_a100_imagenet.csv' + '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_latency_clx_imagenet.csv' ) seed: int = 42 config_name: str = 'subnet' - objective_name: str = 'accuracy_top1' + objective_name: str = 'latency' names = ['subnet', 'date'] + SUPERNET_METRICS[supernet] supernet_manager = SUPERNET_ENCODING[supernet](param_dict=SUPERNET_PARAMETERS[supernet], seed=seed) From 2b091109fdc483c3774761197031ab290da79ba0 Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Wed, 30 Aug 2023 10:03:08 -0700 Subject: [PATCH 4/4] Update Signed-off-by: Maciej Szankin --- generate_predictor_data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/generate_predictor_data.py b/generate_predictor_data.py index a837cbc..de75be1 100644 --- a/generate_predictor_data.py +++ b/generate_predictor_data.py @@ -4,9 +4,9 @@ if __name__ == '__main__': supernet: str = 'ofa_resnet50' - results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_clx8280.csv' + results_path: str = '/nfs/site/home/mszankin/store/nosnap/results/dynast/dynast_ofaresnet50_random_a100.csv' save_to_path: str = ( - '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_latency_clx_imagenet.csv' + '/nfs/site/home/mszankin/store/code/handi/pretrained/predictors/datasets/resnet50_latency_a100_imagenet.csv' ) seed: int = 42 config_name: str = 'subnet' @@ -16,11 +16,13 @@ supernet_manager = SUPERNET_ENCODING[supernet](param_dict=SUPERNET_PARAMETERS[supernet], seed=seed) df = supernet_manager.import_csv(results_path, config=config_name, objective=objective_name, column_names=names) + print(f'Rows: {len(df)}') with open(save_to_path, 'w', newline='', encoding='utf-8') as file: mywriter = csv.writer(file, delimiter=',', lineterminator='\n') for index, row in df.iterrows(): subnet = row['subnet'] - features = subnet['d'] + subnet['e'] + subnet['w'] + features = subnet['d'] + subnet['w'] + subnet['e'] predictor_row = features + [row[objective_name]] mywriter.writerow(predictor_row) + print(f'Saved to: {save_to_path}')