Skip to content

Commit 15cc58a

Browse files
fix(cli): use greedy selector during inference
1 parent 1361d74 commit 15cc58a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libraries/mathy_python/mathy/agents/action_selectors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ def select(
3030
raise NotImplementedError(self.select)
3131

3232

33+
class GreedyActionSelector(ActionSelector):
34+
def select(
35+
self,
36+
*,
37+
last_state: MathyEnvState,
38+
last_window: MathyWindowObservation,
39+
last_action: int,
40+
last_reward: float,
41+
) -> Tuple[int, float]:
42+
probs, value = self.model.predict_next(last_window.to_inputs())
43+
action = np.argmax(probs)
44+
return action, float(value)
45+
46+
3347
class A3CEpsilonGreedyActionSelector(ActionSelector):
3448
def __init__(self, *, epsilon: float, **kwargs):
3549
super(A3CEpsilonGreedyActionSelector, self).__init__(**kwargs)

0 commit comments

Comments
 (0)