def get_param_grids(): lrs = [10**i for i in range(-4, -2)] gd_params = {'learning_rate': [0.0001], 'max_iters': [2000]} rhc_params = { 'learning_rate': [0.1], 'restarts': [100], #[10] 'max_iters': [2000] } sa_params = { 'learning_rate': [0.0001, 0.001, 0.01, 0.1], 'schedule': [ ExpDecay(), ExpDecay(exp_const=0.002), ExpDecay(exp_const=1 / 2000), GeomDecay(), GeomDecay(decay=.999), ArithDecay(), ArithDecay(decay=1 / 2000), ], 'max_iters': [2000] } ga_params = { 'learning_rate': [0.0001, 0.001, 0.01, 0.1], 'pop_size': [400], #[200, 400], #[200] 'mutation_prob': [0.1, .2, .5, .9], 'max_iters': [500] } params = { 'gradient_descent': gd_params, 'random_hill_climb': rhc_params, 'simulated_annealing': sa_params, 'genetic_alg': ga_params } return params
def test_arith_below_min(): """Test arithmetic decay evaluation function for case where result is below the minimum""" schedule = ArithDecay(init_temp=10, decay=0.95, min_temp=1) x = schedule.evaluate(50) assert x == 1
def get_param_grids(): lrs = [10**i for i in range(-4, -2)] gd_params = {'learning_rate': lrs, 'max_iters': [2000]} rhc_params = { 'learning_rate': lrs, 'restarts': [10, 30], #[10] 'max_iters': [2000] } sa_params = { 'learning_rate': lrs, 'schedule': [GeomDecay(), ArithDecay(), ExpDecay()], 'max_iters': [2000] } ga_params = { 'learning_rate': lrs, 'pop_size': [200], #[200] 'mutation_prob': [0.05, 0.1, 0.2], #[0.1] 'max_iters': [500] } params = { 'gradient_descent': gd_params, 'random_hill_climb': rhc_params, 'simulated_annealing': sa_params, 'genetic_alg': ga_params } return params
def get_optimizers(): return { 'RHC': { 'function': random_hill_climb, 'kwargs': [{}], }, 'SA': { 'function': simulated_annealing, 'kwargs': [ { 'schedule': ExpDecay() }, { 'schedule': ExpDecay(exp_const=0.01) }, { 'schedule': ExpDecay(exp_const=0.002) }, { 'schedule': GeomDecay() }, { 'schedule': GeomDecay(decay=.98) }, { 'schedule': GeomDecay(decay=.96) }, { 'schedule': ArithDecay() }, { 'schedule': ArithDecay(decay=0.001) }, { 'schedule': ArithDecay(decay=1 / 5000) }, { 'schedule': ExpDecay(exp_const=0.002) }, ] }, 'GA': { 'function': genetic_alg, 'kwargs': [ { 'pop_size': 200, 'mutation_prob': 0.1 }, { 'pop_size': 200, 'mutation_prob': 0.2 }, { 'pop_size': 200, 'mutation_prob': 0.05 }, { 'pop_size': 800, 'mutation_prob': 0.1 }, ] }, 'MIMIC': { 'function': mimic, 'kwargs': [ { 'pop_size': 200, 'keep_pct': 0.2, #'fast_mimic': True }, { 'pop_size': 200, 'keep_pct': 0.4, #'fast_mimic': True }, { 'pop_size': 400, 'keep_pct': 0.2, }, ] } }
def get_optimizers(): return { #'RHC': { # 'function': random_hill_climb, # 'kwargs': [ # {} # ], #}, 'SA': { 'function': simulated_annealing, 'kwargs': [ { 'schedule': ExpDecay() }, #{'schedule': ExpDecay(exp_const=0.01)}, { 'schedule': ExpDecay(exp_const=0.002) }, { 'schedule': ExpDecay(exp_const=1 / 5000) }, { 'schedule': GeomDecay() }, #{'schedule': GeomDecay(decay=.98)}, { 'schedule': GeomDecay(decay=.9993) }, { 'schedule': ArithDecay() }, #{'schedule': ArithDecay(decay=0.001)}, { 'schedule': ArithDecay(decay=1 / 5000) }, ] }, #'GA': { # 'function': genetic_alg, # 'kwargs': [ # #{'pop_size': 200, # # 'mutation_prob': 0.1 # #}, # #{'pop_size': 200, # # 'mutation_prob': 0.2 # #}, # #{'pop_size': 200, # # 'mutation_prob': 0.05 # #}, # #{'pop_size': 400, # # 'mutation_prob': 0.4 # #}, # #{'pop_size': 400, # # 'mutation_prob': 0.2 # #}, # #{'pop_size': 400, # # 'mutation_prob': 0.1 # #}, # {'pop_size': 800, # 'mutation_prob': 0.1 # }, # ] #}, #'MIMIC': { # 'function': mimic, # 'kwargs': [ # {'pop_size': 400, # 'keep_pct': 0.2, # }, # {'pop_size': 400, # 'keep_pct': 0.1, # }, # {'pop_size': 400, # 'keep_pct': 0.05, # }, # #{'pop_size': 800, # # 'keep_pct': 0.2, # #}, # #{'pop_size': 800, # # 'keep_pct': 0.1, # #}, # ] #} }