diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index f511159..c1e4193 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -59,6 +59,7 @@ Bug Fixes: - Fixed loading of ``ent_coef`` for ``SAC`` and ``TQC``, it was not optimized anymore (thanks @Atlis) - Fixed saving of ``A2C`` and ``PPO`` policy when using gSDE (thanks @liusida) - Fixed a bug where no output would be shown even if ``verbose>=1`` after passing ``verbose=0`` once +- Fixed observation buffers dtype in DictReplayBuffer (@c-rizz) Deprecations: ^^^^^^^^^^^^^ @@ -706,3 +707,4 @@ And all the contributors: @diditforlulz273 @liorcohen5 @ManifoldFR @mloo3 @SwamyDev @wmmc88 @megan-klaiber @thisray @tfederico @hn2 @LucasAlegre @AptX395 @zampanteymedio @JadenTravnik @decodyng @ardabbour @lorenz-h @mschweizer @lorepieri8 @vwxyzjn @ShangqunYu @PierreExeter @JacopoPan @ltbd78 @tom-doerr @Atlis @liusida @09tangriro @amy12xx @juancroldan @benblack769 @bstee615 +@c-rizz diff --git a/stable_baselines3/common/buffers.py b/stable_baselines3/common/buffers.py index 253787d..7530d47 100644 --- a/stable_baselines3/common/buffers.py +++ b/stable_baselines3/common/buffers.py @@ -504,10 +504,12 @@ class DictReplayBuffer(ReplayBuffer): self.optimize_memory_usage = optimize_memory_usage self.observations = { - key: np.zeros((self.buffer_size, self.n_envs) + _obs_shape) for key, _obs_shape in self.obs_shape.items() + key: np.zeros((self.buffer_size, self.n_envs) + _obs_shape, dtype=observation_space[key].dtype) + for key, _obs_shape in self.obs_shape.items() } self.next_observations = { - key: np.zeros((self.buffer_size, self.n_envs) + _obs_shape) for key, _obs_shape in self.obs_shape.items() + key: np.zeros((self.buffer_size, self.n_envs) + _obs_shape, dtype=observation_space[key].dtype) + for key, _obs_shape in self.obs_shape.items() } # only 1 env is supported