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

Function epsilon_greedy

rl/approx_control.py:23–31  ·  view source on GitHub ↗
(model, s, eps=0.1)

Source from the content-addressed store, hash-verified

21
22
23def epsilon_greedy(model, s, eps=0.1):
24 # we'll use epsilon-soft to ensure all states are visited
25 # what happens if you don't do this? i.e. eps=0
26 p = np.random.random()
27 if p < (1 - eps):
28 values = model.predict_all_actions(s)
29 return ALL_POSSIBLE_ACTIONS[np.argmax(values)]
30 else:
31 return np.random.choice(ALL_POSSIBLE_ACTIONS)
32
33
34def one_hot(k):

Callers 1

approx_control.pyFile · 0.70

Calls 1

predict_all_actionsMethod · 0.45

Tested by

no test coverage detected