MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / random_search

Function random_search

rl2/mountaincar/pg_tf_random.py:211–232  ·  view source on GitHub ↗
(env, pmodel, gamma)

Source from the content-addressed store, hash-verified

209
210
211def random_search(env, pmodel, gamma):
212 totalrewards = []
213 best_avg_totalreward = float('-inf')
214 best_pmodel = pmodel
215 num_episodes_per_param_test = 3
216 for t in range(100):
217 tmp_pmodel = best_pmodel.copy()
218
219 tmp_pmodel.perturb_params()
220
221 avg_totalrewards = play_multiple_episodes(
222 env,
223 num_episodes_per_param_test,
224 tmp_pmodel,
225 gamma
226 )
227 totalrewards.append(avg_totalrewards)
228
229 if avg_totalrewards > best_avg_totalreward:
230 best_pmodel = tmp_pmodel
231 best_avg_totalreward = avg_totalrewards
232 return totalrewards, best_pmodel
233
234
235def main():

Callers 1

mainFunction · 0.70

Calls 3

play_multiple_episodesFunction · 0.70
copyMethod · 0.45
perturb_paramsMethod · 0.45

Tested by

no test coverage detected