Skip to content

lit_sb3.buffers.dict_replay

source module lit_sb3.buffers.dict_replay

Classes

  • DictReplayBuffer — Dict Replay buffer used in off-policy algorithms like SAC/TD3.

source class DictReplayBuffer(buffer_size: int, observation_space: spaces.Dict, action_space: spaces.Space, device: torch.device | str = 'auto', n_envs: int = 1, optimize_memory_usage: bool = False, handle_timeout_termination: bool = True)

Bases : ReplayBuffer

Dict Replay buffer used in off-policy algorithms like SAC/TD3.

Extends the ReplayBuffer to use dictionary observations.

Parameters

  • buffer_size : int — Max number of element in the buffer

  • observation_space : spaces.Dict — Observation space

  • action_space : spaces.Space — Action space

  • device : torch.device | str — PyTorch device

  • n_envs : int — Number of parallel environments

  • optimize_memory_usage : bool — Enable a memory efficient variant Disabled for now (see https://github.com/DLR-RM/stable-baselines3/pull/243#discussion_r531535702)

  • handle_timeout_termination : bool — Handle timeout termination (due to timelimit) separately and treat the task as infinite horizon task. https://github.com/DLR-RM/stable-baselines3/issues/284

Methods

  • add

  • sample — Sample elements from the replay buffer.

source method DictReplayBuffer.add(obs: dict[str, np.ndarray], next_obs: dict[str, np.ndarray], action: np.ndarray, reward: np.ndarray, done: np.ndarray, infos: list[dict[str, Any]]) → None

source method DictReplayBuffer.sample(batch_size: int, env: VecNormalize | None = None) → DictReplayBufferSamples

Sample elements from the replay buffer.

Parameters

  • batch_size : int — Number of element to sample

  • env : VecNormalize | None — associated gym VecEnv to normalize the observations/rewards when sampling