From 5f6ad37c37eeac7df716a2d5c44ddac056958b15 Mon Sep 17 00:00:00 2001 From: Arec Jamgochian Date: Mon, 28 Feb 2022 18:56:28 -0800 Subject: [PATCH] updating bc experiment, adding automatic config copying, fixing idm/expert running from file issues in eval_experiments --- bc-experiment.py | 10 ++++++---- eval_experiments.py | 14 +++++++------- gail-experiment.py | 4 +++- shail-experiment.py | 4 +++- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/bc-experiment.py b/bc-experiment.py index 17c5cbe..1f1f0cf 100644 --- a/bc-experiment.py +++ b/bc-experiment.py @@ -142,7 +142,7 @@ if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--train', choices=['A', 'B']) - parser.add_argument('--epochs', type=int, default=1000) + parser.add_argument('--epochs', type=int, default=500) parser.add_argument('--test', type=str, help='path to config file to run final training on') parser.add_argument('--test_seeds', type=int, default=5) parser.add_argument('--test_cpus', type=int, help='number of cpus available to split test seed training over') @@ -163,9 +163,9 @@ if __name__ == '__main__': 'policy': { 'learning_rate': 3e-4, 'learning_rate_decay': tune.grid_search([0.999, 1.0]), - 'hidden_layer_size': tune.grid_search([10, 20, 40, 80]), - 'n_hidden_layers': tune.grid_search([2, 3, 4]), - 'activation':0, + 'hidden_layer_size': tune.grid_search([10, 20, 40]), + 'n_hidden_layers': tune.grid_search([2, 3]), + 'activation':tune.grid_search([0, 1]), }, 'train_epochs': args.epochs, 'seed': 0, @@ -210,3 +210,5 @@ if __name__ == '__main__': check_dir = analysis._checkpoints[i]['logdir'] shutil.copyfile(os.path.join(check_dir,'policy_final.pt'), os.path.join(savepath, f'policy_seed{s}.pt')) + shutil.copyfile(os.path.join(check_dir,'params.json'), + os.path.join(savepath, 'config.json')) # copy config automatically diff --git a/eval_experiments.py b/eval_experiments.py index 53e3684..109c5d5 100644 --- a/eval_experiments.py +++ b/eval_experiments.py @@ -35,12 +35,12 @@ def main(method:str='expert', folder:str=None, locations=[(0,0)], skip_running=F print('%i policy files found in %s folder' %(len(files), folder)) print('found policy config', config['policy']) - policy_config = {k: v for k, v in config['policy'].items() if k not in exclude_keys_from_policy_kwargs} - policy_config['activation'] = activations[policy_config['activation']] - print('final policy config', policy_config) + policy_config = {k: v for k, v in config['policy'].items() if k not in exclude_keys_from_policy_kwargs} + policy_config['activation'] = activations[policy_config['activation']] + print('final policy config', policy_config) - policy_kwargs.update(policy_config) - print('final policy kwargs', policy_kwargs) + policy_kwargs.update(policy_config) + print('final policy kwargs', policy_kwargs) if not skip_running: for policy_file in files: @@ -77,7 +77,7 @@ def latex_print(am, light=False): print('success rate, distance travelled, RWSE_10, |DeltaV|, AccelJSD') if light: if 'rwse_10s' in am.keys(): - print("%2.1f& %2.1f & %1.2f & %2.1f& " + print("%2.1f& %2.1f & %2.1f & %1.2f& " "%0.3f \\\\" %( 100*am['success rate'][0], am['mean travel distance'][0], am['rwse_10s'][0], am['average absolute average velocity'][0],am['acceleration distribution divergence'][0] )) return @@ -88,7 +88,7 @@ def latex_print(am, light=False): return print("%2.1f \\scriptstyle\\pm %2.1f & %2.1f \\scriptstyle\\pm %2.1f & " - "%1.2f \\scriptstyle\\pm %1.2f & %2.1f \\scriptstyle\\pm %1.1f & " + "%2.1f \\scriptstyle\\pm %1.1f & %1.2f \\scriptstyle\\pm %1.2f & " "%0.3f \\scriptstyle\\pm %0.3f \\\\" %( 100*am['success rate'][0], 100*am['success rate'][1], am['mean travel distance'][0] , am['mean travel distance'][1] , am['rwse_10s'][0] , am['rwse_10s'][1] , diff --git a/gail-experiment.py b/gail-experiment.py index 68c9ae9..eb7cec4 100644 --- a/gail-experiment.py +++ b/gail-experiment.py @@ -235,4 +235,6 @@ if __name__ == '__main__': s = analysis._checkpoints[i]['config']['seed'] check_dir = analysis._checkpoints[i]['logdir'] shutil.copyfile(os.path.join(check_dir,'policy_final.pt'), - os.path.join(savepath, f'policy_seed{s}.pt')) \ No newline at end of file + os.path.join(savepath, f'policy_seed{s}.pt')) + shutil.copyfile(os.path.join(check_dir,'params.json'), + os.path.join(savepath, 'config.json')) # copy config automatically \ No newline at end of file diff --git a/shail-experiment.py b/shail-experiment.py index 598efa9..e46d6bc 100644 --- a/shail-experiment.py +++ b/shail-experiment.py @@ -258,4 +258,6 @@ if __name__ == '__main__': s = analysis._checkpoints[i]['config']['seed'] check_dir = analysis._checkpoints[i]['logdir'] shutil.copyfile(os.path.join(check_dir,'policy_final.pt'), - os.path.join(savepath, f'policy_seed{s}.pt')) \ No newline at end of file + os.path.join(savepath, f'policy_seed{s}.pt')) + shutil.copyfile(os.path.join(check_dir,'params.json'), + os.path.join(savepath, 'config.json')) # copy config automatically \ No newline at end of file