From c722c4f5bdb5b1e78b06c18574b3f146cace687d Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Mon, 1 Feb 2021 11:24:44 +0100 Subject: [PATCH] Fix numpy warning and update migration guide (#307) --- docs/guide/migration.rst | 1 + docs/misc/changelog.rst | 4 +++- stable_baselines3/common/base_class.py | 2 +- stable_baselines3/common/callbacks.py | 2 +- stable_baselines3/common/vec_env/dummy_vec_env.py | 2 +- stable_baselines3/version.txt | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/guide/migration.rst b/docs/guide/migration.rst index d7dffb5..2bc8e65 100644 --- a/docs/guide/migration.rst +++ b/docs/guide/migration.rst @@ -49,6 +49,7 @@ Breaking Changes - We dropped GAIL support as we are focusing on model-free RL only, you can however take a look at the :ref:`imitation project ` which implements GAIL and other imitation learning algorithms on top of SB3. - ``action_probability`` is currently not implemented in the base class +- ``pretrain()`` method for behavior cloning was removed (see `issue #27 `_) You can take a look at the `issue about SB3 implementation design `_ for more details. diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index daa8e79..1fdee75 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -3,7 +3,7 @@ Changelog ========== -Pre-Release 0.11.0a6 (WIP) +Pre-Release 0.11.0a7 (WIP) ------------------------------- Breaking Changes: @@ -38,6 +38,7 @@ Bug Fixes: - Added informative ``PPO`` construction error in edge-case scenario where ``n_steps * n_envs = 1`` (size of rollout buffer), which otherwise causes downstream breaking errors in training (@decodyng) - Fixed discrete observation space support when using multiple envs with A2C/PPO (thanks @ardabbour) +- Fixed numpy warning (replaced ``np.bool`` with ``bool``) Deprecations: ^^^^^^^^^^^^^ @@ -66,6 +67,7 @@ Documentation: - Fix docstring of classes in atari_wrappers.py which were inside the constructor (@LucasAlegre) - Added SB3-Contrib page - Fix bug in the example code of DQN (@AptX395) +- Updated migration guide Pre-Release 0.10.0 (2020-10-28) ------------------------------- diff --git a/stable_baselines3/common/base_class.py b/stable_baselines3/common/base_class.py index 59f1a3b..8785ea3 100644 --- a/stable_baselines3/common/base_class.py +++ b/stable_baselines3/common/base_class.py @@ -377,7 +377,7 @@ class BaseAlgorithm(ABC): # Avoid resetting the environment when calling ``.learn()`` consecutive times if reset_num_timesteps or self._last_obs is None: self._last_obs = self.env.reset() - self._last_dones = np.zeros((self.env.num_envs,), dtype=np.bool) + self._last_dones = np.zeros((self.env.num_envs,), dtype=bool) # Retrieve unnormalized observation for saving into the buffer if self._vec_normalize_env is not None: self._last_original_obs = self._vec_normalize_env.get_original_obs() diff --git a/stable_baselines3/common/callbacks.py b/stable_baselines3/common/callbacks.py index 8e89d91..fa806a8 100644 --- a/stable_baselines3/common/callbacks.py +++ b/stable_baselines3/common/callbacks.py @@ -447,7 +447,7 @@ class StopTrainingOnRewardThreshold(BaseCallback): def _on_step(self) -> bool: assert self.parent is not None, "``StopTrainingOnMinimumReward`` callback must be used " "with an ``EvalCallback``" - # Convert np.bool to bool, otherwise callback() is False won't work + # Convert np.bool_ to bool, otherwise callback() is False won't work continue_training = bool(self.parent.best_mean_reward < self.reward_threshold) if self.verbose > 0 and not continue_training: print( diff --git a/stable_baselines3/common/vec_env/dummy_vec_env.py b/stable_baselines3/common/vec_env/dummy_vec_env.py index a1a2382..5eb87cd 100644 --- a/stable_baselines3/common/vec_env/dummy_vec_env.py +++ b/stable_baselines3/common/vec_env/dummy_vec_env.py @@ -29,7 +29,7 @@ class DummyVecEnv(VecEnv): self.keys, shapes, dtypes = obs_space_info(obs_space) self.buf_obs = OrderedDict([(k, np.zeros((self.num_envs,) + tuple(shapes[k]), dtype=dtypes[k])) for k in self.keys]) - self.buf_dones = np.zeros((self.num_envs,), dtype=np.bool) + self.buf_dones = np.zeros((self.num_envs,), dtype=bool) self.buf_rews = np.zeros((self.num_envs,), dtype=np.float32) self.buf_infos = [{} for _ in range(self.num_envs)] self.actions = None diff --git a/stable_baselines3/version.txt b/stable_baselines3/version.txt index cebd346..9522e5b 100644 --- a/stable_baselines3/version.txt +++ b/stable_baselines3/version.txt @@ -1 +1 @@ -0.11.0a6 +0.11.0a7