-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathobserver.py
More file actions
28 lines (22 loc) · 794 Bytes
/
observer.py
File metadata and controls
28 lines (22 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from numpy import exp
class EpsilonUpdater:
def __init__(self, agent):
self.agent = agent
def __call__(self, event):
if event == 'step_done':
self.epsilon_update()
self.switch_learning()
else:
pass
def epsilon_update(self):
self.agent.epsilon = (
self.agent.epsilon_min +
(self.agent.epsilon_max - self.agent.epsilon_min) * exp(
-self.agent.epsilon_decay * self.agent.step_count_total))
pass
def switch_learning(self):
if self.agent.step_count_total >= self.agent.learning_start:
self.agent.learning_switch = True
pass