getting best shail/hail configs outsave up and running, adding shell for test runs
This commit is contained in:
33
best_configs/hail_expA.json
Normal file
33
best_configs/hail_expA.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 2,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
best_configs/hail_expB.json
Normal file
33
best_configs/hail_expB.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": null,
|
||||||
|
"abort_unsafe_collision_method": null
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 2,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
best_configs/shail_expA.json
Normal file
33
best_configs/shail_expA.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "A",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 2,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
33
best_configs/shail_expB.json
Normal file
33
best_configs/shail_expB.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"experiment": "B",
|
||||||
|
"trainenv": {
|
||||||
|
"stop_on_collision": false,
|
||||||
|
"safe_actions_collision_method": "circle",
|
||||||
|
"abort_unsafe_collision_method": "circle"
|
||||||
|
},
|
||||||
|
"policy": {
|
||||||
|
"learning_rate": 0.0003,
|
||||||
|
"learning_rate_decay": 1.0,
|
||||||
|
"clip_ratio": 0.2,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"hidden_layer_size": 20,
|
||||||
|
"n_hidden_layers": 2,
|
||||||
|
"activation": 0,
|
||||||
|
"option": 0
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"iterations_per_epoch": 1000
|
||||||
|
},
|
||||||
|
"discriminator": {
|
||||||
|
"learning_rate": 0.001,
|
||||||
|
"weight_decay": 0.0001,
|
||||||
|
"iterations_per_epoch": 100,
|
||||||
|
"n_hidden_layers_element": 3,
|
||||||
|
"n_hidden_layers_global": 1,
|
||||||
|
"hidden_layer_size": 10,
|
||||||
|
"activation": 0
|
||||||
|
},
|
||||||
|
"train_epochs": 2,
|
||||||
|
"seed": 0
|
||||||
|
}
|
||||||
@@ -142,8 +142,8 @@ def training_function(config):
|
|||||||
v_opt=v_opt,
|
v_opt=v_opt,
|
||||||
v_iters=config['value']['iterations_per_epoch'],
|
v_iters=config['value']['iterations_per_epoch'],
|
||||||
epochs=config['train_epochs'],
|
epochs=config['train_epochs'],
|
||||||
rollout_episodes=60,
|
rollout_episodes=6, #60, FIXME
|
||||||
rollout_steps=60,
|
rollout_steps=6, #60, FIXME
|
||||||
gamma=0.99,
|
gamma=0.99,
|
||||||
gae_lambda=0.9,
|
gae_lambda=0.9,
|
||||||
clip_ratio=config['policy']['clip_ratio'],
|
clip_ratio=config['policy']['clip_ratio'],
|
||||||
@@ -162,44 +162,78 @@ if __name__ == '__main__':
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('experiment', choices=['A', 'B'])
|
parser.add_argument('experiment', choices=['A', 'B'])
|
||||||
parser.add_argument('--epochs', type=int, default=200)
|
parser.add_argument('--epochs', type=int, default=200)
|
||||||
|
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)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# if no test config specified, train
|
||||||
|
if args.test is None:
|
||||||
|
print('Running Tuning for Experiment %s'%(args.experiment))
|
||||||
|
analysis = tune.run(
|
||||||
|
training_function,
|
||||||
|
config={
|
||||||
|
'experiment': args.experiment,
|
||||||
|
'trainenv': {
|
||||||
|
'stop_on_collision': False,
|
||||||
|
'safe_actions_collision_method': 'circle',
|
||||||
|
'abort_unsafe_collision_method': 'circle',
|
||||||
|
},
|
||||||
|
'policy': {
|
||||||
|
'learning_rate': 3e-4,
|
||||||
|
'learning_rate_decay': 1.0,
|
||||||
|
'clip_ratio': 0.2,
|
||||||
|
'iterations_per_epoch': 100,
|
||||||
|
'hidden_layer_size': tune.grid_search([20, 40]),
|
||||||
|
'n_hidden_layers': tune.grid_search([2, 3]),
|
||||||
|
'activation':0,
|
||||||
|
'option': tune.grid_search(list(range(len(option_list))))
|
||||||
|
},
|
||||||
|
'value': {
|
||||||
|
'learning_rate': 1e-3,
|
||||||
|
'iterations_per_epoch': 1000,
|
||||||
|
},
|
||||||
|
'discriminator': {
|
||||||
|
'learning_rate': 1e-3,
|
||||||
|
'weight_decay': 1e-4,
|
||||||
|
'iterations_per_epoch': 100,
|
||||||
|
'n_hidden_layers_element': tune.grid_search([3,4]),
|
||||||
|
'n_hidden_layers_global': tune.grid_search([1,2]),
|
||||||
|
'hidden_layer_size': 10,
|
||||||
|
'activation': 0,
|
||||||
|
},
|
||||||
|
'train_epochs': args.epochs,
|
||||||
|
'seed': 0,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
best_config = analysis.get_best_config(metric='gen_collision_rate', mode='min')
|
||||||
|
print('Best config: ', best_config)
|
||||||
|
|
||||||
print('Running Tuning for Experiment %s'%(args.experiment))
|
# safe best_config
|
||||||
analysis = tune.run(
|
if not os.path.isdir(os.path.join(DIR, 'best_configs')):
|
||||||
training_function,
|
os.mkdir(os.path.join(DIR, 'best_configs'))
|
||||||
config={
|
|
||||||
'experiment': args.experiment,
|
# save shail
|
||||||
'trainenv': {
|
with open(os.path.join(DIR, 'best_configs',f'shail_exp{args.experiment}.json'), 'w', encoding='utf-8') as f:
|
||||||
'stop_on_collision': False,
|
json.dump(best_config, f, ensure_ascii=False, indent=4)
|
||||||
'safe_actions_collision_method': 'circle',
|
|
||||||
'abort_unsafe_collision_method': 'circle',
|
# save hail
|
||||||
},
|
best_config['trainenv']['safe_actions_collision_method']=None
|
||||||
'policy': {
|
best_config['trainenv']['abort_unsafe_collision_method']=None
|
||||||
'learning_rate': 3e-4,
|
with open(os.path.join(DIR, 'best_configs',f'hail_exp{args.experiment}.json'), 'w', encoding='utf-8') as f:
|
||||||
'learning_rate_decay': 1.0,
|
json.dump(best_config, f, ensure_ascii=False, indent=4)
|
||||||
'clip_ratio': 0.2,
|
|
||||||
'iterations_per_epoch': 100,
|
# if config file specified, rerun it with appropriate number of seeds
|
||||||
'hidden_layer_size': tune.grid_search([20, 40]),
|
else:
|
||||||
'n_hidden_layers': tune.grid_search([2, 3]),
|
with open(args.test, 'rb') as f:
|
||||||
'activation':0,
|
config = json.load(f)
|
||||||
'option': tune.grid_search(list(range(len(option_list))))
|
|
||||||
},
|
print(f'Retraining {args.test} with {args.test_seed} seeds on experiment {config["experiment"]}')
|
||||||
'value': {
|
|
||||||
'learning_rate': 1e-3,
|
# rerun with appropriate number of seeds
|
||||||
'iterations_per_epoch': 1000,
|
config['seed'] = tune.grid_search(list(range(1,args.test_seeds+1)))
|
||||||
},
|
analysis = tune.run(training_function, config)
|
||||||
'discriminator': {
|
|
||||||
'learning_rate': 1e-3,
|
# move final policies to appropriate directory
|
||||||
'weight_decay': 1e-4,
|
# import pdb
|
||||||
'iterations_per_epoch': 100,
|
# pdb.set_trace()
|
||||||
'n_hidden_layers_element': tune.grid_search([3,4]),
|
# a = 0
|
||||||
'n_hidden_layers_global': tune.grid_search([1,2]),
|
|
||||||
'hidden_layer_size': 10,
|
|
||||||
'activation': 0,
|
|
||||||
},
|
|
||||||
'train_epochs': args.epochs,
|
|
||||||
'seed': 0,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print('Best config: ', analysis.get_best_config(metric='gen_collision_rate', mode='min'))
|
|
||||||
Reference in New Issue
Block a user