araffin / rl-tutorial-jnrr19

Stable-Baselines tutorial for Journées Nationales de la Recherche en Robotique 2019
MIT License
591 stars 113 forks source link

Typos inside Notebook 4 Callbacks and hyperparameter tuning #1

Closed basso95 closed 4 years ago

basso95 commented 4 years ago

In the final exercise

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.

araffin commented 4 years ago

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 ;)