class EvalCallback(object):
"""
Callback for evaluating an agent.
:param eval_env: (gym.Env) The environment used for initialization
:param n_eval_episodes: (int) The number of episodes to test the agent
:param eval_freq: (int) Evaluate the agent every eval_freq call of the callback.
"""
def __init(self, eval_env, n_eval_episodes=5, eval_freq=20):
super(EvalCallback, self).__init__()
self.eval_env = eval_env
self.n_eval_episodes = n_eval_episodes
self.eval_freq = eval_freq
self.n_calls = 0
self.best_mean_reward = -np.inf
def __call__(self, locals_, globals_):
"""
This method will be called by the model. This is the equivalent to the callback function
used the previous examples.
:param locals_: (dict)
:param globals_: (dict)
:return: (bool)
"""
# Get the self object of the model
self_ = locals['self']
It should be __init__ instead of __init, and inside the __call__ method we call locals['self'], which should be locals_['self'] instead.
Hello,
thanks for spotting the typos (in fact this exercise was added after the first session), i would appreciate if you could submit a PR that solves this issue ;)
In the final exercise
It should be
__init__
instead of__init
, and inside the__call__
method we calllocals['self']
, which should belocals_['self']
instead.