I am using hypterameter_search.py script to find the optimal parameter combination. My box constraint settings are:
box_constraints = {'learning_rate': [-7, -3], 'num_layers': [1, 3], 'num_nodes': [2, 20] , 'lr_decay': [0.001,0.1], 'L2_reg': [0.05, 0.01, 0.1, 1, 3, 5.0] }
However, when I ran the script, it showed an error message: Box constraints improperly specified: should be [lb, ub] pairs
The error is fixed when I define L2_reg as a length 2 array (e.g. 'L2_reg': [0.05, 0.01]). Why do all the parameter have to have length 2? I am not sure if I am missing something here. I put my main function code here. Your help would be greatly appreciated!
By reading more about optunity package, it seems like L2_reg should be pairs. The first element in the pair should be the lower bound, and the second element should be the upper bound.
I am using hypterameter_search.py script to find the optimal parameter combination. My box constraint settings are:
box_constraints = {'learning_rate': [-7, -3], 'num_layers': [1, 3], 'num_nodes': [2, 20] , 'lr_decay': [0.001,0.1], 'L2_reg': [0.05, 0.01, 0.1, 1, 3, 5.0] }
However, when I ran the script, it showed an error message:Box constraints improperly specified: should be [lb, ub] pairs
The error is fixed when I define L2_reg as a length 2 array (e.g. 'L2_reg': [0.05, 0.01]). Why do all the parameter have to have length 2? I am not sure if I am missing something here. I put my main function code here. Your help would be greatly appreciated!
if __name__ == '__main__':
import deepsurv
os.chdir('/Users/yudeng/Downloads/DeepSurv-master')
NUM_EPOCHS = 100
NUM_FOLDS = 5
logdir = './hyperparam_search/logs/tensorboard/'
main_logger = load_logger(logdir)
#box_constraints = load_box_constraints('/Users/yudeng/Downloads/DeepSurv-master/hyperparam_search/box_constraints.0.json')
box_constraints = {'learning_rate': [-7, -3], 'num_layers': [1, 3], 'num_nodes': [2, 20]
, 'lr_decay': [0.001,0.1], 'L2_reg': [0.05, 0.01, 0.1, 1, 3, 5.0] }
update_fn= 'sgd'
num_evals = 5
opt_fxn = get_objective_function(NUM_EPOCHS, logdir, utils.get_optimizer_from_str(update_fn))
opt_fxn = optunity.cross_validated(x=x, y=y, num_folds=NUM_FOLDS, strata=False)(opt_fxn)
main_logger.debug('Maximizing C-Index. Num_iterations: %d' % num_evals)
opt_params, call_log, _ = optunity.maximize(opt_fxn, ``num_evals=num_evals,solver_name='sobol',**box_constraints)
main_logger.debug('Optimal Parameters: ' + str(opt_params))
main_logger.debug('Saving Call log...')
print(call_log._asdict())
save_call_log(os.path.join(args.logdir, 'optunity_log_%s.pkl' % (str(uuid.uuid4()))), call_log._asdict())
exit(0)