Skip to content

DictReplayStorage

source

DictReplayStorage(
   observation_space: gym.Space, action_space: gym.Space, device: str = 'cpu',
   storage_size: int = 1000000, batch_size: int = 1024, num_envs: int = 1
)


Dict replay storage for off-policy algorithms and dictionary observations.

Args

  • observation_space (gym.Space) : Observation space.
  • action_space (gym.Space) : Action space.
  • device (str) : Device to convert the data.
  • storage_size (int) : The capacity of the storage.
  • batch_size (int) : Batch size of samples.
  • num_envs (int) : The number of parallel environments.

Returns

Dict replay storage.

Methods:

.reset

source

.reset()


Reset the storage.

.add

source

.add(
   observations: Dict[str, th.Tensor], actions: th.Tensor, rewards: th.Tensor,
   terminateds: th.Tensor, truncateds: th.Tensor, infos: Dict[str, Any],
   next_observations: Dict[str, th.Tensor]
)


Add sampled transitions into storage.

Args

  • observations (Dict[str, th.Tensor]) : Observations.
  • actions (th.Tensor) : Actions.
  • rewards (th.Tensor) : Rewards.
  • terminateds (th.Tensor) : Termination flag.
  • truncateds (th.Tensor) : Truncation flag.
  • infos (Dict[str, Any]) : Additional information.
  • next_observations (Dict[str, th.Tensor]) : Next observations.

Returns

None.

.sample

source

.sample()


Sample from the storage.

.update

source

.update(
   *args, **kwargs
)


Update the storage if necessary.